mirror of
https://github.com/lrsjng/h5ai.git
synced 2025-05-24 12:07:10 -04:00
Add some tests.
This commit is contained in:
parent
e52b3dd440
commit
0e0f06d634
3 changed files with 44 additions and 2 deletions
|
@ -16,10 +16,9 @@ const mainrowTpl =
|
|||
</div>`;
|
||||
|
||||
const init = () => {
|
||||
dom('#fallback, #fallback-hints').rm();
|
||||
|
||||
const $root = dom(rootSelector)
|
||||
.attr('id', 'root')
|
||||
.clr()
|
||||
.app(topbarTpl)
|
||||
.app(mainrowTpl);
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ require('./tests/premisses');
|
|||
require('./tests/unit/core/event');
|
||||
require('./tests/unit/core/format');
|
||||
require('./tests/unit/util/naturalCmp');
|
||||
require('./tests/unit/util/parsePatten');
|
||||
|
||||
pinHtml();
|
||||
|
||||
|
|
42
test/tests/unit/util/parsePatten.js
Normal file
42
test/tests/unit/util/parsePatten.js
Normal file
|
@ -0,0 +1,42 @@
|
|||
const {test, assert, insp} = require('scar');
|
||||
const {parsePattern} = require('../../../../src/_h5ai/public/js/lib/util');
|
||||
|
||||
test('util.parsePattern is function', () => {
|
||||
assert.equal(typeof parsePattern, 'function');
|
||||
});
|
||||
|
||||
[
|
||||
['', false, ''],
|
||||
[' ', false, '\\ '],
|
||||
['a', false, 'a'],
|
||||
['ä', false, 'ä'],
|
||||
['á', false, 'á'],
|
||||
['*', false, '\\*'],
|
||||
['ab', false, 'ab'],
|
||||
['rea', false, 'rea'],
|
||||
['re:', false, 're:'],
|
||||
['re:a', false, 're:a'],
|
||||
['a b', false, 'a\\ b'],
|
||||
['ab c', false, 'ab\\ c'],
|
||||
[' a ', false, '\\ a\\ '],
|
||||
|
||||
['', true, ''],
|
||||
[' ', true, ''],
|
||||
['a', true, 'a'],
|
||||
['ä', true, 'ä'],
|
||||
['á', true, 'á'],
|
||||
['*', true, '\\*'],
|
||||
['ab', true, 'a.*?b'],
|
||||
['rea', true, 'r.*?e.*?a'],
|
||||
[' re:', true, 'r.*?e.*?:'],
|
||||
['are:', true, 'a.*?r.*?e.*?:'],
|
||||
['re:', true, ''],
|
||||
['re:a', true, 'a'],
|
||||
['a b', true, 'a|b'],
|
||||
['ab c', true, 'a.*?b|c'],
|
||||
[' a ', true, 'a']
|
||||
].forEach(([pattern, advanced, exp]) => {
|
||||
test(`util.parsePattern(${insp(pattern)}, ${insp(advanced)}) === ${insp(exp)}`, () => {
|
||||
assert.equal(parsePattern(pattern, advanced), exp);
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue