forked from nodejs/node-core-utils
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcomp.test.js
More file actions
31 lines (25 loc) · 755 Bytes
/
comp.test.js
File metadata and controls
31 lines (25 loc) · 755 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import { describe, it } from 'node:test';
import assert from 'node:assert';
import { ascending, descending } from '../../lib/utils.js';
const arr = [
'2017-10-30T15:47:52Z',
'2017-10-30T15:19:37Z'
];
describe('Comparison', () => {
it('should sort by ascending', () => {
assert.deepStrictEqual(
['2017-10-30T15:19:37Z', '2017-10-30T15:47:52Z'],
arr.sort(ascending)
);
assert.strictEqual(ascending(0, 1), -1);
assert.strictEqual(ascending(1, 0), 1);
});
it('should sort by descending', () => {
assert.deepStrictEqual(
['2017-10-30T15:47:52Z', '2017-10-30T15:19:37Z'],
arr.sort(descending)
);
assert.strictEqual(descending(0, 1), 1);
assert.strictEqual(descending(1, 0), -1);
});
});