mirror of
https://github.com/tenrok/BBob.git
synced 2026-06-14 18:42:24 +03:00
feat: typescript support (#185)
* feat: initial typescript support * feat: typescript support * feat(plugin-helper): move files to typescript * chore: update lock files * feat: preset types * fix: build * fix: benchmark * fix: remove pnpm cache * fix: bench action * fix: pnpm recursive install * fix: nx cache * fix: lock file * fix: workflows * fix: lerna support in pnpm * fix: pnpm workspace * fix: remove unused files * fix: pnpm lock file * fix: update lerna for support pnpm * fix: lerna bootstrap * fix: rollup build * fix: update nx * fix: build * fix: add nx dep target * fix: remove nx cache * fix: workflow run on push only for master * fix: test workflow run on push only for master * fix: remove parallel for gen types * fix: benchmark * fix: benchmark imports * fix: pnpm * fix: types errors and pnpm * fix: types * fix: types * refactor: parser * fix(parser): tests * fix: preset tests * fix: react types * fix: react type declarations * fix: pnpm lock file * fix: react preset types * fix: lock file * fix: vue2 types * feat: dev container support * fix: types * fix: types * refactor: rewrite pkg-task, add nx gen-types deps, fix react/render.ts * refactor: types * fix: types * fix: rename gen-types to types * fix: nx build order * fix: nx reset * fix: define nx deps explicit * fix: build * fix: nx * fix: nx order build * fix: nx deps * fix: bbob cli tests * fix: tests * fix: cli tests and import * fix: test cover * fix: cli cover
This commit is contained in:
@@ -0,0 +1,91 @@
|
||||
import { createCharGrabber } from '../src/utils';
|
||||
|
||||
|
||||
describe('utils', () => {
|
||||
describe('createCharGrabber', () => {
|
||||
|
||||
test('#substrUntilChar ] 1', () => {
|
||||
/**
|
||||
|
||||
}
|
||||
*/
|
||||
const bufferGrabber = createCharGrabber('[h1 name=value]Foo [Bar] [/h1]');
|
||||
const substr = bufferGrabber.substrUntilChar(']');
|
||||
|
||||
expect(substr).toBe('[h1 name=value');
|
||||
});
|
||||
|
||||
test('#substrUntilChar ] 2', () => {
|
||||
/**
|
||||
console.log src/utils.js:95
|
||||
substrUntilChar { char: ']', indexOfChar: 63, curPos: 0 } {
|
||||
result: '[url href=https://ru.wikipedia.org target=_blank text="Foo Bar"',
|
||||
source: '[url href=https://ru.wikipedia.org target=_blank text="Foo Bar"]Text[/url]'
|
||||
}
|
||||
console.log src/utils.js:104
|
||||
substrUntilChar.new { char: ']', indexOfCharNew: 63, curPos: 0 } {
|
||||
result: '[url href=https://ru.wikipedia.org target=_blank text="Foo Bar"]',
|
||||
source: '[url href=https://ru.wikipedia.org target=_blank text="Foo Bar"]Text[/url]'
|
||||
}
|
||||
*/
|
||||
const bufferGrabber = createCharGrabber('[url href=https://ru.wikipedia.org target=_blank text="Foo Bar"]Text[/url]');
|
||||
const substr = bufferGrabber.substrUntilChar(']');
|
||||
|
||||
expect(substr).toBe('[url href=https://ru.wikipedia.org target=_blank text="Foo Bar"');
|
||||
});
|
||||
|
||||
test('#substrUntilChar ] 3', () => {
|
||||
/**
|
||||
console.log src/utils.js:95
|
||||
substrUntilChar { char: ']', indexOfChar: 14, curPos: 7 } {
|
||||
result: 'blah foo="bar"',
|
||||
source: 'hello [blah foo="bar"]world[/blah]'
|
||||
}
|
||||
console.log src/utils.js:104
|
||||
substrUntilChar.new { char: ']', indexOfCharNew: 21, curPos: 7 } {
|
||||
result: 'blah foo="bar"]world[/',
|
||||
source: 'hello [blah foo="bar"]world[/blah]'
|
||||
}
|
||||
*/
|
||||
const bufferGrabber = createCharGrabber('hello [blah foo="bar"]world[/blah]');
|
||||
const substr = bufferGrabber.substrUntilChar('[');
|
||||
|
||||
expect(substr).toBe('hello ');
|
||||
});
|
||||
|
||||
test('#substrUntilChar not existed', () => {
|
||||
/**
|
||||
console.log src/utils.js:95
|
||||
substrUntilChar { char: ']', indexOfChar: 14, curPos: 7 } {
|
||||
result: 'blah foo="bar"',
|
||||
source: 'hello [blah foo="bar"]world[/blah]'
|
||||
}
|
||||
console.log src/utils.js:104
|
||||
substrUntilChar.new { char: ']', indexOfCharNew: 21, curPos: 7 } {
|
||||
result: 'blah foo="bar"]world[/',
|
||||
source: 'hello [blah foo="bar"]world[/blah]'
|
||||
}
|
||||
*/
|
||||
const bufferGrabber = createCharGrabber('hello');
|
||||
const substr = bufferGrabber.substrUntilChar('[');
|
||||
|
||||
expect(substr).toBe('');
|
||||
});
|
||||
|
||||
test('getPrev is null', () => {
|
||||
const bufferGrabber = createCharGrabber('');
|
||||
const prev = bufferGrabber.getPrev();
|
||||
|
||||
expect(prev).toBe(null);
|
||||
});
|
||||
|
||||
test('getRest', () => {
|
||||
const bufferGrabber = createCharGrabber('hello [blah foo="bar"]world[/blah]');
|
||||
bufferGrabber.skip();
|
||||
const rest = bufferGrabber.getRest();
|
||||
|
||||
expect(rest).toBe('ello [blah foo="bar"]world[/blah]');
|
||||
});
|
||||
|
||||
})
|
||||
});
|
||||
Reference in New Issue
Block a user