|
| 1 | +import {runCommand} from '@oclif/test' |
| 2 | +import {expect} from 'chai' |
| 3 | +import nock from 'nock' |
| 4 | +import stripAnsi from 'strip-ansi' |
| 5 | + |
| 6 | +describe('features:enable', function () { |
| 7 | + afterEach(() => nock.cleanAll()) |
| 8 | + |
| 9 | + it('enables an app feature', async () => { |
| 10 | + nock('https://api.heroku.com:443') |
| 11 | + .get('/apps/myapp/features/feature-a') |
| 12 | + .reply(200, {enabled: false}) |
| 13 | + .patch('/apps/myapp/features/feature-a', {enabled: true}) |
| 14 | + .reply(200) |
| 15 | + |
| 16 | + const {stdout, stderr} = await runCommand(['features:enable', 'feature-a', '--app', 'myapp']) |
| 17 | + |
| 18 | + expect(stdout).to.equal('') |
| 19 | + expect(stderr).to.contain('Enabling feature-a for') |
| 20 | + expect(stderr).to.contain('myapp') |
| 21 | + expect(stderr).to.contain('done') |
| 22 | + }) |
| 23 | + |
| 24 | + it('errors if feature is already enabled', async () => { |
| 25 | + nock('https://api.heroku.com:443') |
| 26 | + .get('/apps/myapp/features/feature-a') |
| 27 | + .reply(200, {enabled: true}) |
| 28 | + |
| 29 | + const {error} = await runCommand(['features:enable', '-a', 'myapp', 'feature-a']) |
| 30 | + |
| 31 | + expect(stripAnsi(error?.message || '')).to.equal('feature-a is already enabled.') |
| 32 | + }) |
| 33 | +}) |
0 commit comments