forked from react-native-community/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuninstall.test.js
55 lines (47 loc) · 1.46 KB
/
uninstall.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
51
52
53
54
55
// @flow
import {run, getTempDirectory, cleanup, writeFiles} from '../jest/helpers';
const DIR = getTempDirectory('command-uninstall-test');
const pkg = 'react-native-config';
beforeEach(() => {
cleanup(DIR);
writeFiles(DIR, {
'node_modules/react-native/package.json': '{}',
'node_modules/react-native-config/package.json': '{}',
'package.json': `{
"dependencies": {
"react-native-config": "*"
}
}`,
});
});
afterEach(() => cleanup(DIR));
test('uninstall fails when package is not defined', () => {
writeFiles(DIR, {
'package.json': `{
"dependencies": {}
}`,
});
const {stderr, code} = run(DIR, ['uninstall'], {expectedFailure: true});
expect(stderr).toContain('missing required argument');
expect(code).toBe(1);
});
test('uninstall fails when package is not installed', () => {
writeFiles(DIR, {
'package.json': `{
"dependencies": {}
}`,
});
const {stderr, code} = run(DIR, ['uninstall', pkg], {expectedFailure: true});
expect(stderr).toContain(`Failed to unlink "${pkg}".`);
expect(code).toBe(1);
});
test.each(['yarn', 'npm'])('uninstall module with %s', pm => {
if (pm === 'yarn') {
writeFiles(DIR, {'yarn.lock': ''});
}
const {stdout, code} = run(DIR, ['uninstall', pkg]);
expect(stdout).toContain(`Unlinking "${pkg}"`);
expect(stdout).toContain(`Uninstalling "${pkg}"`);
expect(stdout).toContain(`Successfully uninstalled and unlinked "${pkg}"`);
expect(code).toBe(0);
});