mirror of
https://github.com/lrsjng/h5ai.git
synced 2025-05-28 22:16:00 -04:00
Add tests.
This commit is contained in:
parent
691cbce10f
commit
3fe1b2d6f8
2 changed files with 44 additions and 0 deletions
|
@ -8,6 +8,7 @@ const {pinHtml} = require('./util/pin');
|
|||
require('./tests/premisses');
|
||||
require('./tests/unit/core/event');
|
||||
require('./tests/unit/core/format');
|
||||
require('./tests/unit/util/naturalCmp');
|
||||
|
||||
pinHtml();
|
||||
|
||||
|
|
43
test/tests/unit/util/naturalCmp.js
Normal file
43
test/tests/unit/util/naturalCmp.js
Normal file
|
@ -0,0 +1,43 @@
|
|||
const {test, assert, insp} = require('scar');
|
||||
const {naturalCmp} = require('../../../../src/_h5ai/public/js/lib/util');
|
||||
|
||||
test('util.naturalCmp is function', () => {
|
||||
assert.equal(typeof naturalCmp, 'function');
|
||||
});
|
||||
|
||||
[
|
||||
'-1',
|
||||
'0',
|
||||
'00',
|
||||
'000',
|
||||
'001',
|
||||
'01',
|
||||
'02',
|
||||
'1',
|
||||
'3',
|
||||
'a0',
|
||||
'a00',
|
||||
'a1',
|
||||
'a2',
|
||||
'a 0',
|
||||
'a 00',
|
||||
'a 000',
|
||||
'a 01',
|
||||
'a 1',
|
||||
'a 2',
|
||||
'a 3',
|
||||
'a.1',
|
||||
'a.1.0',
|
||||
'a.1.1',
|
||||
'a.1.1.0',
|
||||
'a.1.10',
|
||||
'z'
|
||||
].forEach((b, idx, arr) => {
|
||||
if (idx === 0) {
|
||||
return;
|
||||
}
|
||||
const a = arr[idx - 1];
|
||||
test(`util.naturalCmp(): ${insp(a)} < ${insp(b)}`, () => {
|
||||
assert.equal(naturalCmp(a, b), -1);
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue