-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
50 lines (37 loc) · 1.04 KB
/
test.js
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
'use strict';
const { join } = require('path');
const { pathExists } = require('fs-extra');
const execa = require('execa');
const fixtures = require('fixturez');
const f = fixtures(__dirname);
const realCWD = process.cwd();
let tmpPath;
beforeEach(() => {
tmpPath = f.copy('fixtures');
});
it('deletes files', async () => {
expect.assertions(4);
const folders = [
join(tmpPath, 'foo'),
join(tmpPath, 'bar'),
join(tmpPath, 'nested'),
];
await execa(join(realCWD, 'cli.js'), folders.concat(`--cwd=${tmpPath}`));
expect(await pathExists('foo')).toBe(false);
expect(await pathExists('bar')).toBe(false);
expect(await pathExists('nested')).toBe(false);
expect(await pathExists(tmpPath)).toBe(true);
});
it('logs deleted files', async () => {
expect.assertions(1);
const folders = [
join(tmpPath, 'foo'),
join(tmpPath, 'bar'),
join(tmpPath, 'nested'),
];
const res = await execa(
join(realCWD, 'cli.js'),
folders.concat(`--cwd=${tmpPath}`)
);
expect(res.stdout.search('Deleted')).not.toBe(-1);
});