mirror of
https://github.com/lrsjng/h5ai.git
synced 2025-05-24 03:57:08 -04:00
Clean some tests.
This commit is contained in:
parent
f0bee58869
commit
834f3b5425
4 changed files with 73 additions and 101 deletions
|
@ -1,18 +1,9 @@
|
||||||
const {test, assert} = require('scar');
|
const {test, assert} = require('scar');
|
||||||
const event = require('../../../../src/_h5ai/public/js/lib/core/event');
|
const event = require('../../../../src/_h5ai/public/js/lib/core/event');
|
||||||
|
|
||||||
test('event is object', () => {
|
test('core.event', () => {
|
||||||
assert.equal(typeof event, 'object');
|
assert.equal(typeof event, 'object', 'is object');
|
||||||
});
|
assert.deepEqual(Object.keys(event).sort(), ['sub', 'pub'].sort());
|
||||||
|
|
||||||
test('event has the right props', () => {
|
|
||||||
assert.deepEqual(Object.keys(event), ['sub', 'pub']);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('event.sub is function', () => {
|
|
||||||
assert.equal(typeof event.sub, 'function');
|
assert.equal(typeof event.sub, 'function');
|
||||||
});
|
|
||||||
|
|
||||||
test('event.pub is function', () => {
|
|
||||||
assert.equal(typeof event.pub, 'function');
|
assert.equal(typeof event.pub, 'function');
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,26 +1,11 @@
|
||||||
const {test, assert} = require('scar');
|
const {test, assert} = require('scar');
|
||||||
const format = require('../../../../src/_h5ai/public/js/lib/core/format');
|
const format = require('../../../../src/_h5ai/public/js/lib/core/format');
|
||||||
|
|
||||||
test('format is object', () => {
|
test('core.format', () => {
|
||||||
assert.equal(typeof format, 'object');
|
assert.equal(typeof format, 'object');
|
||||||
});
|
assert.deepEqual(Object.keys(format).sort(), ['setDefaultMetric', 'formatSize', 'setDefaultDateFormat', 'formatDate'].sort());
|
||||||
|
|
||||||
test('format has the right props', () => {
|
|
||||||
assert.deepEqual(Object.keys(format), ['setDefaultMetric', 'formatSize', 'setDefaultDateFormat', 'formatDate']);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('format.setDefaultMetric is function', () => {
|
|
||||||
assert.equal(typeof format.setDefaultMetric, 'function');
|
assert.equal(typeof format.setDefaultMetric, 'function');
|
||||||
});
|
|
||||||
|
|
||||||
test('format.formatSize is function', () => {
|
|
||||||
assert.equal(typeof format.formatSize, 'function');
|
assert.equal(typeof format.formatSize, 'function');
|
||||||
});
|
|
||||||
|
|
||||||
test('format.setDefaultDateFormat is function', () => {
|
|
||||||
assert.equal(typeof format.setDefaultDateFormat, 'function');
|
assert.equal(typeof format.setDefaultDateFormat, 'function');
|
||||||
});
|
|
||||||
|
|
||||||
test('format.formatDate is function', () => {
|
|
||||||
assert.equal(typeof format.formatDate, 'function');
|
assert.equal(typeof format.formatDate, 'function');
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,43 +1,41 @@
|
||||||
const {test, assert, insp} = require('scar');
|
const {test, assert, insp} = require('scar');
|
||||||
const {naturalCmp} = require('../../../../src/_h5ai/public/js/lib/util');
|
const {naturalCmp} = require('../../../../src/_h5ai/public/js/lib/util');
|
||||||
|
|
||||||
test('util.naturalCmp is function', () => {
|
test('util.naturalCmp()', () => {
|
||||||
assert.equal(typeof naturalCmp, 'function');
|
assert.equal(typeof naturalCmp, 'function', 'is function');
|
||||||
});
|
|
||||||
|
|
||||||
[
|
[
|
||||||
'-1',
|
'-1',
|
||||||
'0',
|
'0',
|
||||||
'00',
|
'00',
|
||||||
'000',
|
'000',
|
||||||
'001',
|
'001',
|
||||||
'01',
|
'01',
|
||||||
'02',
|
'02',
|
||||||
'1',
|
'1',
|
||||||
'3',
|
'3',
|
||||||
'a0',
|
'a0',
|
||||||
'a00',
|
'a00',
|
||||||
'a1',
|
'a1',
|
||||||
'a2',
|
'a2',
|
||||||
'a 0',
|
'a 0',
|
||||||
'a 00',
|
'a 00',
|
||||||
'a 000',
|
'a 000',
|
||||||
'a 01',
|
'a 01',
|
||||||
'a 1',
|
'a 1',
|
||||||
'a 2',
|
'a 2',
|
||||||
'a 3',
|
'a 3',
|
||||||
'a.1',
|
'a.1',
|
||||||
'a.1.0',
|
'a.1.0',
|
||||||
'a.1.1',
|
'a.1.1',
|
||||||
'a.1.1.0',
|
'a.1.1.0',
|
||||||
'a.1.10',
|
'a.1.10',
|
||||||
'z'
|
'z'
|
||||||
].forEach((b, idx, arr) => {
|
].forEach((b, idx, arr) => {
|
||||||
if (idx === 0) {
|
if (idx === 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const a = arr[idx - 1];
|
const a = arr[idx - 1];
|
||||||
test(`util.naturalCmp(): ${insp(a)} < ${insp(b)}`, () => {
|
assert.equal(naturalCmp(a, b), -1, `fix#${idx} - ${insp(a)} < ${insp(b)}`);
|
||||||
assert.equal(naturalCmp(a, b), -1);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,42 +1,40 @@
|
||||||
const {test, assert, insp} = require('scar');
|
const {test, assert, insp} = require('scar');
|
||||||
const {parsePattern} = require('../../../../src/_h5ai/public/js/lib/util');
|
const {parsePattern} = require('../../../../src/_h5ai/public/js/lib/util');
|
||||||
|
|
||||||
test('util.parsePattern is function', () => {
|
test('util.parsePattern()', () => {
|
||||||
assert.equal(typeof parsePattern, 'function');
|
assert.equal(typeof parsePattern, 'function', 'is function');
|
||||||
});
|
|
||||||
|
|
||||||
[
|
[
|
||||||
['', false, ''],
|
['', false, ''],
|
||||||
[' ', false, '\\ '],
|
[' ', false, '\\ '],
|
||||||
['a', false, 'a'],
|
['a', false, 'a'],
|
||||||
['ä', false, 'ä'],
|
['ä', false, 'ä'],
|
||||||
['á', false, 'á'],
|
['á', false, 'á'],
|
||||||
['*', false, '\\*'],
|
['*', false, '\\*'],
|
||||||
['ab', false, 'ab'],
|
['ab', false, 'ab'],
|
||||||
['rea', false, 'rea'],
|
['rea', false, 'rea'],
|
||||||
['re:', false, 're:'],
|
['re:', false, 're:'],
|
||||||
['re:a', false, 're:a'],
|
['re:a', false, 're:a'],
|
||||||
['a b', false, 'a\\ b'],
|
['a b', false, 'a\\ b'],
|
||||||
['ab c', false, 'ab\\ c'],
|
['ab c', false, 'ab\\ c'],
|
||||||
[' a ', false, '\\ a\\ '],
|
[' a ', false, '\\ a\\ '],
|
||||||
|
|
||||||
['', true, ''],
|
['', true, ''],
|
||||||
[' ', true, ''],
|
[' ', true, ''],
|
||||||
['a', true, 'a'],
|
['a', true, 'a'],
|
||||||
['ä', true, 'ä'],
|
['ä', true, 'ä'],
|
||||||
['á', true, 'á'],
|
['á', true, 'á'],
|
||||||
['*', true, '\\*'],
|
['*', true, '\\*'],
|
||||||
['ab', true, 'a.*?b'],
|
['ab', true, 'a.*?b'],
|
||||||
['rea', true, 'r.*?e.*?a'],
|
['rea', true, 'r.*?e.*?a'],
|
||||||
[' re:', true, 'r.*?e.*?:'],
|
[' re:', true, 'r.*?e.*?:'],
|
||||||
['are:', true, 'a.*?r.*?e.*?:'],
|
['are:', true, 'a.*?r.*?e.*?:'],
|
||||||
['re:', true, ''],
|
['re:', true, ''],
|
||||||
['re:a', true, 'a'],
|
['re:a', true, 'a'],
|
||||||
['a b', true, 'a|b'],
|
['a b', true, 'a|b'],
|
||||||
['ab c', true, 'a.*?b|c'],
|
['ab c', true, 'a.*?b|c'],
|
||||||
[' a ', true, 'a']
|
[' a ', true, 'a']
|
||||||
].forEach(([pattern, advanced, exp]) => {
|
].forEach(([pattern, advanced, exp], idx) => {
|
||||||
test(`util.parsePattern(${insp(pattern)}, ${insp(advanced)}) === ${insp(exp)}`, () => {
|
assert.equal(parsePattern(pattern, advanced), exp, `fix#${idx} - (${insp(pattern)}, ${insp(advanced)}) -> ${insp(exp)}`);
|
||||||
assert.equal(parsePattern(pattern, advanced), exp);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue