-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.mjs
88 lines (70 loc) · 2.74 KB
/
test.mjs
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
import test from 'ava';
import shell from 'shelljs';
import pjson from './package.json' assert { type: "json" };
import { promisify } from 'util';
const promisifiedExec = promisify(shell.exec);
test('Birth Time Test', async t => {
const results = await promisifiedExec("node index.js -iRl './test' -e 'hello' -sort:birthtime", { silent:true });
t.is(results.trim(),
'./test/file_four.docx 8/25/2018, 1:02:09 PM\n' +
'./test/file_three.md 8/25/2018, 12:59:37 PM\n' +
'./test/file_two.js 8/25/2018, 12:59:37 PM'
);
});
test('Limit Test', async t => {
const results = await promisifiedExec("node index.js -iRl './test' -e 'hello' -sort:birthtime,,2", { silent:true });
t.is(results.trim(),
'./test/file_four.docx 8/25/2018, 1:02:09 PM\n' +
'./test/file_three.md 8/25/2018, 12:59:37 PM'
);
});
test('Asc Test', async t => {
const results = await promisifiedExec("node index.js -iRl './test' -e 'hello' -sort:birthtime,asc", { silent:true });
t.is(results.trim(),
'./test/file_three.md 8/25/2018, 12:59:37 PM\n' +
'./test/file_two.js 8/25/2018, 12:59:37 PM\n' +
'./test/file_four.docx 8/25/2018, 1:02:09 PM'
);
});
test('Version Test', async t => {
const results = await promisifiedExec("node index.js -V", { silent:true });
t.is(results.trim(), pjson.version);
});
test('birthtimeMs Test', async t => {
const results = await promisifiedExec("node index.js -iRl './test' -e 'hello' -sort:birthtimeMs", { silent:true });
t.is(results.trim(),
'./test/file_four.docx 1535216529000\n' +
'./test/file_three.md 1535216377000\n' +
'./test/file_two.js 1535216377000'
);
});
test('Custom Sort Test', async t => {
const results = await promisifiedExec("node index.js -iRl './test' -e 'hello' -sort:birthtimeMs,asc,1", { silent:true });
t.is(results.trim(),
'./test/file_three.md 1535216377000'
);
});
test('No Limit Test', async t => {
const results = await promisifiedExec("node index.js -iRl './test' -e 'hello' -sort:birthtimeMs,,0", { silent:true });
t.is(results.trim(),
'./test/file_four.docx 1535216529000\n' +
'./test/file_three.md 1535216377000\n' +
'./test/file_two.js 1535216377000'
);
});
test('Default Sort Test', async t => {
const results = await promisifiedExec("node index.js -iRl './test' -e 'hello'", { silent:true });
t.is(results.trim(),
'./test/file_four.docx 8/25/2018, 1:03:51 PM\n' +
'./test/file_three.md 8/25/2018, 12:59:37 PM\n' +
'./test/file_two.js 8/25/2018, 12:59:37 PM'
);
});
test('UID Sort Test', async t => {
const results = await promisifiedExec("node index.js -iRl './test' -e 'hello' -sort:uid", { silent:true });
t.is(results.trim(),
'./test/file_four.docx 501\n' +
'./test/file_three.md 501\n' +
'./test/file_two.js 501'
);
});