-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcli.spec.js
More file actions
35 lines (29 loc) · 1.06 KB
/
cli.spec.js
File metadata and controls
35 lines (29 loc) · 1.06 KB
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
const test = require('ava');
const util = require('util');
const path = require('path');
const exec = util.promisify(require('child_process').exec);
const glob = util.promisify(require('glob'));
const cmd = './cli'
const cwd = 'fixtures';
let fixtures = [];
test.before(async () => {
fixtures = await glob('**/*.js', { cwd });
});
test.serial('should link the directories and the files which match the pattern', async (t) => {
const { stderr } = await exec([cmd, cwd].join(' '));
const lines = stderr.split('\n');
t.deepEqual(lines, [
'3 Directories linked!',
'8 Files linked!',
''
]);
});
test.serial('should check if files are created', async (t) => {
const files = await glob('**/*.js', { cwd: process.cwd() });
const genFiles = files.filter((value, index, self) => fixtures.indexOf(value) !== -1);
t.is(genFiles.length, 8);
});
test.serial('should clean all the linked folders and files when the flag --clean it\'s used', async (t) => {
const { stderr } = await exec([cmd, cwd, '--clean'].join(' '));
t.is(stderr, '5 Files cleaned!\n');
});