This repository has been archived by the owner on Dec 15, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 292
/
enable-spec.coffee
105 lines (83 loc) · 2.87 KB
/
enable-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
path = require 'path'
temp = require 'temp'
CSON = require 'season'
apm = require '../lib/apm-cli'
describe 'apm enable', ->
beforeEach ->
silenceOutput()
spyOnToken()
it 'enables a disabled 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: [
"metrics"
"vim-mode"
"exception-reporting"
"file-icons"
]
runs ->
apm.run(['enable', 'vim-mode', 'not-installed', 'file-icons'], callback)
waitsFor 'waiting for enable to complete', ->
callback.callCount > 0
runs ->
expect(console.log).toHaveBeenCalled()
expect(console.log.argsForCall[0][0]).toMatch /Not Disabled:\s*not-installed/
expect(console.log.argsForCall[1][0]).toMatch /Enabled:\s*vim-mode/
config = CSON.readFileSync(configFilePath)
expect(config).toEqual '*':
core:
disabledPackages: [
"metrics"
"exception-reporting"
]
it 'does nothing if a package is already enabled', ->
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: [
"metrics"
"exception-reporting"
]
runs ->
apm.run(['enable', 'vim-mode'], callback)
waitsFor 'waiting for enable to complete', ->
callback.callCount > 0
runs ->
expect(console.log).toHaveBeenCalled()
expect(console.log.argsForCall[0][0]).toMatch /Not Disabled:\s*vim-mode/
config = CSON.readFileSync(configFilePath)
expect(config).toEqual '*':
core:
disabledPackages: [
"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(['enable', 'vim-mode'], callback)
waitsFor 'waiting for enable 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(['enable'], callback)
waitsFor 'waiting for enable to complete', ->
callback.callCount > 0
runs ->
expect(console.error).toHaveBeenCalled()
expect(console.error.argsForCall[0][0].length).toBeGreaterThan 0