mirror of
https://github.com/lrsjng/h5ai.git
synced 2025-08-25 14:10:41 +02:00
Clean some tests.
This commit is contained in:
@@ -1,43 +1,41 @@
|
||||
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');
|
||||
});
|
||||
test('util.naturalCmp()', () => {
|
||||
assert.equal(typeof naturalCmp, 'function', 'is 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);
|
||||
[
|
||||
'-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];
|
||||
assert.equal(naturalCmp(a, b), -1, `fix#${idx} - ${insp(a)} < ${insp(b)}`);
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user