This repository has been archived by the owner on Nov 3, 2020. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(actions): add few tests for list
- Loading branch information
Satya Rohith
committed
Dec 25, 2018
1 parent
da0c94c
commit b84c7a2
Showing
1 changed file
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
const {expect, test} = require('@oclif/test'); | ||
|
||
describe('actions:list', () => { | ||
test | ||
.nock('https://api.digitalocean.com/v2', api => | ||
api.get('/actions?tag_name=&page=1').reply(200, { | ||
meta: { | ||
total: 0 | ||
} | ||
}) | ||
) | ||
.stdout() | ||
.command(['actions:list']) | ||
.it('shows no actions performed message', ctx => { | ||
expect(ctx.stdout).to.contain("You haven't perfomed any actions\n"); | ||
}); | ||
|
||
const expectedOutput = `ID Status Resource type Resource id Type Started at Completed at Region \n593116925 completed droplet 125046402 destroy 2018-12-25T05:35:26Z 2018-12-25T05:35:28Z ncy1 \nCurrent Page: 1\nTotal Pages: 1\n`; | ||
|
||
test | ||
.nock('https://api.digitalocean.com/v2', api => | ||
api.get('/actions?tag_name=&page=1').reply(200, { | ||
actions: [ | ||
{ | ||
id: 593116925, | ||
status: 'completed', | ||
resource_type: 'droplet', | ||
resource_id: 125046402, | ||
type: 'destroy', | ||
started_at: '2018-12-25T05:35:26Z', | ||
completed_at: '2018-12-25T05:35:28Z', | ||
region_slug: 'ncy1' | ||
} | ||
], | ||
links: {}, | ||
meta: { | ||
total: 1 | ||
} | ||
}) | ||
) | ||
.stdout() | ||
.command(['actions:list']) | ||
.it('lists actions successfully', ctx => { | ||
expect(ctx.stdout).to.equal(expectedOutput); | ||
}); | ||
}); |