UNPKG

1.19 kBJavaScriptView Raw
1/* eslint-env mocha */
2
3const nock = require('nock')
4const expect = require('chai').expect
5const cli = require('heroku-cli-util')
6const cmd = require('../../../commands/ci/list')
7const stdMocks = require('std-mocks')
8
9describe('heroku ci:list', function () {
10 let app, coupling, runs
11
12 beforeEach(function () {
13 cli.mockConsole()
14 app = '123-app'
15
16 coupling = {
17 pipeline: {
18 id: '123-abc',
19 name: 'test-pipeline'
20 }
21 }
22 runs = [{
23 number: 123,
24 commit_branch: 'foo',
25 commit_sha: '1234567',
26 status: 'running'
27 }]
28 })
29
30 it('displays recent runs', function* () {
31 const api = nock('https://api.heroku.com')
32 .get(`/apps/${app}/pipeline-couplings`)
33 .reply(200, coupling)
34 .get(`/pipelines/${coupling.pipeline.id}/test-runs`)
35 .reply(200, runs)
36
37 stdMocks.use()
38
39 yield cmd.run({ app, flags: {} })
40
41 stdMocks.restore()
42 const { stdout } = stdMocks.flush()
43
44 expect(stdout[0]).to.contain(runs[0].number)
45 expect(stdout[0]).to.contain(runs[0].commit_branch)
46 expect(stdout[0]).to.contain(runs[0].commit_sha)
47 expect(stdout[0]).to.contain(runs[0].status)
48
49 api.done()
50 })
51})