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
|
const t = require('tap')
const InstallTest = require('../../lib/install-test.js')
let installArgs = null
let installCalled = false
let testArgs = null
let testCalled = false
let installError = null
const installTest = new InstallTest({
commands: {
install: (args, cb) => {
installArgs = args
installCalled = true
cb(installError)
},
test: (args, cb) => {
testArgs = args
testCalled = true
cb()
},
},
})
t.test('the install-test command', t => {
t.afterEach(cb => {
installArgs = null
installCalled = false
testArgs = null
testCalled = false
installError = null
cb()
})
t.test('install and test', t => {
installTest.exec(['extra'], () => {
t.equal(installCalled, true)
t.equal(testCalled, true)
t.match(installArgs, ['extra'])
t.match(testArgs, [])
t.end()
})
})
t.test('install fails', t => {
installError = new Error('test fail')
installTest.exec(['extra'], (err) => {
t.equal(installCalled, true)
t.equal(testCalled, false)
t.match(installArgs, ['extra'])
t.match(err, { message: 'test fail' })
t.end()
})
})
t.end()
})
|