-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdisable-spec.coffee
113 lines (91 loc) · 3.38 KB
/
disable-spec.coffee
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
101
102
103
104
105
106
107
108
109
110
111
112
113
fs = require 'fs-plus'
wrench = require 'wrench'
path = require 'path'
temp = require 'temp'
CSON = require 'season'
apm = require '../lib/apm-cli'
describe 'apm disable', ->
beforeEach ->
silenceOutput()
spyOnToken()
it 'disables an enabled package', ->
atomHome = temp.mkdirSync('apm-home-dir-')
process.env.ATOM_HOME = atomHome
callback = jasmine.createSpy('callback')
configFilePath = path.join(atomHome, 'config.cson')
CSON.writeFileSync configFilePath, '*':
core:
disabledPackages: [
"test-module"
]
packagesPath = path.join(atomHome, 'packages')
packageSrcPath = path.join(__dirname, 'fixtures')
fs.makeTreeSync(packagesPath)
wrench.copyDirSyncRecursive(path.join(packageSrcPath, 'test-module'), path.join(packagesPath, 'test-module'))
wrench.copyDirSyncRecursive(path.join(packageSrcPath, 'test-module-two'), path.join(packagesPath, 'test-module-two'))
wrench.copyDirSyncRecursive(path.join(packageSrcPath, 'test-module-three'), path.join(packagesPath, 'test-module-three'))
runs ->
apm.run(['disable', 'test-module-two', 'not-installed', 'test-module-three'], callback)
waitsFor 'waiting for disable to complete', ->
callback.callCount > 0
runs ->
expect(console.log).toHaveBeenCalled()
expect(console.log.argsForCall[0][0]).toMatch /Not Installed:\s*not-installed/
expect(console.log.argsForCall[1][0]).toMatch /Disabled:\s*test-module-two/
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', ->
atomHome = temp.mkdirSync('apm-home-dir-')
process.env.ATOM_HOME = atomHome
callback = jasmine.createSpy('callback')
configFilePath = path.join(atomHome, 'config.cson')
CSON.writeFileSync configFilePath, '*':
core:
disabledPackages: [
"vim-mode"
"file-icons"
"metrics"
"exception-reporting"
]
runs ->
apm.run(['disable', 'vim-mode', 'metrics'], callback)
waitsFor 'waiting for disable to complete', ->
callback.callCount > 0
runs ->
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', ->
atomHome = temp.mkdirSync('apm-home-dir-')
process.env.ATOM_HOME = atomHome
callback = jasmine.createSpy('callback')
runs ->
apm.run(['disable', 'vim-mode'], callback)
waitsFor 'waiting for disable to complete', ->
callback.callCount > 0
runs ->
expect(console.error).toHaveBeenCalled()
expect(console.error.argsForCall[0][0].length).toBeGreaterThan 0
it 'complains if user supplies no packages', ->
atomHome = temp.mkdirSync('apm-home-dir-')
process.env.ATOM_HOME = atomHome
callback = jasmine.createSpy('callback')
runs ->
apm.run(['disable'], callback)
waitsFor 'waiting for disable to complete', ->
callback.callCount > 0
runs ->
expect(console.error).toHaveBeenCalled()
expect(console.error.argsForCall[0][0].length).toBeGreaterThan 0