cloudcmd 17.1.6 → 17.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ChangeLog +10 -1
- package/HELP.md +3 -2
- package/README.md +1 -1
- package/dist/sw.js +1 -1
- package/dist-dev/sw.js +1 -1
- package/package.json +3 -2
- package/server/{cloudcmd.js → cloudcmd.mjs} +52 -48
- package/server/cloudcmd.spec.mjs +180 -0
- package/server/config.spec.mjs +105 -0
- package/server/distribute/export.spec.mjs +68 -0
- package/server/distribute/import.spec.mjs +287 -0
- package/server/markdown/index.spec.mjs +126 -0
- package/server/rest/index.js +21 -18
- package/server/route.spec.mjs +458 -0
- package/server/server.mjs +6 -6
- package/server/terminal.js +6 -2
- package/server/terminal.spec.mjs +73 -0
- package/server/{user-menu.js → user-menu.mjs} +17 -17
- package/server/user-menu.spec.mjs +74 -0
- package/server/validate.spec.mjs +104 -0
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import {test, stub} from 'supertape';
|
|
2
|
+
import tryCatch from 'try-catch';
|
|
3
|
+
import validate from './validate.js';
|
|
4
|
+
import cloudcmd from './cloudcmd.mjs';
|
|
5
|
+
|
|
6
|
+
test('validate: root: bad', (t) => {
|
|
7
|
+
const config = {
|
|
8
|
+
root: Math.random(),
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const [e] = tryCatch(cloudcmd, {
|
|
12
|
+
config,
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
t.equal(e.message, 'dir should be a string', 'should throw');
|
|
16
|
+
t.end();
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
test('validate: root: config', (t) => {
|
|
20
|
+
const config = stub().returns(true);
|
|
21
|
+
|
|
22
|
+
validate.root('/hello', config);
|
|
23
|
+
|
|
24
|
+
t.calledWith(config, ['dropbox'], 'should call config');
|
|
25
|
+
t.end();
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
test('validate: root: /', (t) => {
|
|
29
|
+
const fn = stub();
|
|
30
|
+
validate.root('/', fn);
|
|
31
|
+
|
|
32
|
+
t.notCalled(fn, 'should not call fn');
|
|
33
|
+
t.end();
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
test('validate: root: stat', (t) => {
|
|
37
|
+
const config = stub();
|
|
38
|
+
const error = 'ENOENT';
|
|
39
|
+
const statSync = stub().throws(Error(error));
|
|
40
|
+
const exit = stub();
|
|
41
|
+
|
|
42
|
+
validate.root('hello', config, {
|
|
43
|
+
statSync,
|
|
44
|
+
exit,
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
const msg = 'cloudcmd --root: %s';
|
|
48
|
+
|
|
49
|
+
t.calledWith(exit, [msg, error], 'should call fn');
|
|
50
|
+
t.end();
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
test('validate: packer: not valid', (t) => {
|
|
54
|
+
const exit = stub();
|
|
55
|
+
const msg = 'cloudcmd --packer: could be "tar" or "zip" only';
|
|
56
|
+
|
|
57
|
+
validate.packer('hello', {
|
|
58
|
+
exit,
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
t.calledWith(exit, [msg], 'should call fn');
|
|
62
|
+
t.end();
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
test('validate: editor: not valid', (t) => {
|
|
66
|
+
const exit = stub();
|
|
67
|
+
const msg = 'cloudcmd --editor: could be "dword", "edward" or "deepword" only';
|
|
68
|
+
|
|
69
|
+
validate.editor('hello', {
|
|
70
|
+
exit,
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
t.calledWith(exit, [msg], 'should call fn');
|
|
74
|
+
t.end();
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
test('validate: columns', (t) => {
|
|
78
|
+
const exit = stub();
|
|
79
|
+
|
|
80
|
+
validate.columns('name-size-date', {
|
|
81
|
+
exit,
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
t.notCalled(exit, 'should not call exit');
|
|
85
|
+
t.end();
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
test('validate: columns: wrong', (t) => {
|
|
89
|
+
const getColumns = stub().returns({
|
|
90
|
+
'name-size-date': '',
|
|
91
|
+
'name-size': '',
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
const exit = stub();
|
|
95
|
+
const msg = 'cloudcmd --columns: can be only one of: "name-size-date", "name-size"';
|
|
96
|
+
|
|
97
|
+
validate.columns('hello', {
|
|
98
|
+
exit,
|
|
99
|
+
getColumns,
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
t.calledWith(exit, [msg], 'should call exit');
|
|
103
|
+
t.end();
|
|
104
|
+
});
|