Welcome to mirror list, hosted at ThFree Co, Russian Federation.

install-ci-test.js « lib « test - github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 5f30efcabf2597f7de3aea9b1902ab0ee967f9bc (plain)
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 InstallCITest = require('../../lib/install-ci-test.js')

let ciArgs = null
let ciCalled = false
let testArgs = null
let testCalled = false
let ciError = null

const installCITest = new InstallCITest({
  commands: {
    ci: (args, cb) => {
      ciArgs = args
      ciCalled = true
      cb(ciError)
    },
    test: (args, cb) => {
      testArgs = args
      testCalled = true
      cb()
    },
  },
})

t.test('the install-ci-test command', t => {
  t.afterEach(cb => {
    ciArgs = null
    ciCalled = false
    testArgs = null
    testCalled = false
    ciError = null
    cb()
  })

  t.test('ci and test', t => {
    installCITest.exec(['extra'], () => {
      t.equal(ciCalled, true)
      t.equal(testCalled, true)
      t.match(ciArgs, ['extra'])
      t.match(testArgs, [])
      t.end()
    })
  })

  t.test('ci fails', t => {
    ciError = new Error('test fail')
    installCITest.exec(['extra'], (err) => {
      t.equal(ciCalled, true)
      t.equal(testCalled, false)
      t.match(ciArgs, ['extra'])
      t.match(err, { message: 'test fail' })
      t.end()
    })
  })
  t.end()
})