-
-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathdisable-spec.js
More file actions
100 lines (88 loc) · 3.05 KB
/
disable-spec.js
File metadata and controls
100 lines (88 loc) · 3.05 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
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
89
90
91
92
93
94
95
96
97
98
99
100
const fs = require('fs-plus');
const fsPromises = require('fs/promises');
const path = require('path');
const temp = require('temp');
const CSON = require('season');
describe('apm disable', () => {
beforeEach(() => {
silenceOutput();
spyOnToken();
});
it('disables an enabled package', async () => {
const atomHome = temp.mkdirSync('apm-home-dir-');
process.env.ATOM_HOME = atomHome;
const configFilePath = path.join(atomHome, 'config.cson');
CSON.writeFileSync(configFilePath, {
'*': {
core: {
disabledPackages: ['test-module']
}
}
});
const packagesPath = path.join(atomHome, 'packages');
const packageSrcPath = path.join(__dirname, 'fixtures');
fs.makeTreeSync(packagesPath);
await fsPromises.cp(
path.join(packageSrcPath, 'test-module'),
path.join(packagesPath, 'test-module'),
{ recursive: true }
);
await fsPromises.cp(
path.join(packageSrcPath, 'test-module-two'),
path.join(packagesPath, 'test-module-two'),
{ recursive: true }
);
await fsPromises.cp(
path.join(packageSrcPath, 'test-module-three'),
path.join(packagesPath, 'test-module-three'),
{ recursive: true }
);
await apmRun(['disable', 'test-module-two', 'not-installed', 'test-module-three']);
expect(console.log).toHaveBeenCalled();
expect(console.log.calls.argsFor(0)[0]).toMatch(/Not Installed:\s*not-installed/);
expect(console.log.calls.argsFor(1)[0]).toMatch(/Disabled:\s*test-module-two/);
const config = CSON.readFileSync(configFilePath);
expect(config).toEqual({
'*': {
core: {
disabledPackages: ['test-module', 'test-module-two', 'test-module-three']
}
}
});
});
it('does nothing if a package is already disabled', async () => {
const atomHome = temp.mkdirSync('apm-home-dir-');
process.env.ATOM_HOME = atomHome;
const configFilePath = path.join(atomHome, 'config.cson');
CSON.writeFileSync(configFilePath, {
'*': {
core: {
disabledPackages: ['vim-mode', 'file-icons', 'metrics', 'exception-reporting']
}
}
});
await apmRun(['disable', 'vim-mode', 'metrics']);
const config = CSON.readFileSync(configFilePath);
expect(config).toEqual({
'*': {
core: {
disabledPackages: ['vim-mode', 'file-icons', 'metrics', 'exception-reporting']
}
}
});
});
it('produces an error if config.cson doesn\'t exist', async () => {
const atomHome = temp.mkdirSync('apm-home-dir-');
process.env.ATOM_HOME = atomHome;
await apmRun(['disable', 'vim-mode']);
expect(console.error).toHaveBeenCalled();
expect(console.error.calls.argsFor(0)[0].length).toBeGreaterThan(0);
});
it('complains if user supplies no packages', async () => {
const atomHome = temp.mkdirSync('apm-home-dir-');
process.env.ATOM_HOME = atomHome;
await apmRun(['disable']);
expect(console.error).toHaveBeenCalled();
expect(console.error.calls.argsFor(0)[0].length).toBeGreaterThan(0);
});
});