-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(serviceList): Add serviceList class method
Add serviceList class method to list all the services of the account
- Loading branch information
1 parent
f5d2adc
commit 990522c
Showing
4 changed files
with
104 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
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
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,27 @@ | ||
'use strict'; | ||
|
||
module.exports.serviceList = [ | ||
{ | ||
'comment': '', | ||
'customer_id': 'x4xCwxxJxGCx123Rx5xTx', | ||
'id': 'SU1Z0isxPaozGVKXdv0eY', | ||
'name': 'test service', | ||
'version': 1, | ||
'versions': [ | ||
{ | ||
'active': null, | ||
'comment': '', | ||
'created_at': '2016-04-27T19:40:49', | ||
'deleted_at': null, | ||
'deployed': null, | ||
'locked': '1', | ||
'number': '1', | ||
'service': 'SU1Z0isxPaozGVKXdv0eY', | ||
'service_id': 'SU1Z0isxPaozGVKXdv0eY', | ||
'staging': null, | ||
'testing': null, | ||
'updated_at': '2016-05-09T16:27:00' | ||
} | ||
] | ||
} | ||
]; |
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,44 @@ | ||
'use strict'; | ||
|
||
const nock = require('nock'); | ||
const expect = require('expect'); | ||
const config = require('../src/config'); | ||
const fastlyPromises = require('../src/index'); | ||
const response = require('./response/serviceList.response'); | ||
|
||
describe('#serviceList', () => { | ||
const fastly = fastlyPromises('923b6bd5266a7f932e41962755bd4254', 'SU1Z0isxPaozGVKXdv0eY'); | ||
let res; | ||
|
||
nock(config.mainEntryPoint) | ||
.get('/service') | ||
.reply(200, response.serviceList); | ||
|
||
before(async () => { | ||
res = await fastly.serviceList(); | ||
}); | ||
|
||
it('response should be a status 200', () => { | ||
expect(res.status).toBe(200); | ||
}); | ||
|
||
it('response body should exist', () => { | ||
expect(res.data).toExist(); | ||
}); | ||
|
||
it('response body should be an array', () => { | ||
expect(Array.isArray(res.data)).toBe(true); | ||
}); | ||
|
||
it('response body should be an array of objects', () => { | ||
res.data.forEach(item => { | ||
expect(item).toBeA('object'); | ||
}); | ||
}); | ||
|
||
it('response body items should have comment, customer_id, id, name, version, and versions properties', () => { | ||
res.data.forEach(item => { | ||
expect(item).toIncludeKeys(['comment', 'customer_id', 'id', 'name', 'version', 'versions']); | ||
}); | ||
}); | ||
}); |