-
Notifications
You must be signed in to change notification settings - Fork 216
/
index.unit.test.js
53 lines (45 loc) · 1.11 KB
/
index.unit.test.js
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
'use strict'
/* global beforeEach afterEach */
const cli = require('heroku-cli-util')
const {expect} = require('chai')
const nock = require('nock')
const proxyquire = require('proxyquire')
const addon = {
id: 1,
name: 'postgres-1',
plan: {name: 'heroku-postgresql:standard-0'},
}
const fetcher = () => {
return {
all: () => [addon],
addon: () => addon,
}
}
const cmd = proxyquire('../../../../commands/links', {
'../../lib/fetcher': fetcher,
})
describe('pg:links', () => {
let api
let pg
beforeEach(() => {
api = nock('https://api.heroku.com')
pg = nock('https://postgres-api.heroku.com')
cli.mockConsole()
})
afterEach(() => {
nock.cleanAll()
api.done()
pg.done()
})
it('shows links', () => {
pg.get('/client/v11/databases/1/links').reply(200, [
{name: 'redis-link-1', created_at: '100', remote: {attachment_name: 'REDIS', name: 'redis-001'}},
])
return cmd.run({app: 'myapp', args: {}, flags: {confirm: 'myapp'}})
.then(() => expect(cli.stdout).to.equal(`=== postgres-1
* redis-link-1
created_at: 100
remote: REDIS (redis-001)
`))
})
})