Skip to content

Commit d208bdb

Browse files
committed
Stack, organization and role unit test
1 parent bb72449 commit d208bdb

3 files changed

Lines changed: 14 additions & 9 deletions

File tree

lib/stack/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ export function Stack (http, data) {
3232
this.stackHeaders = { api_key: this.api_key }
3333
if (this.management_token && this.management_token) {
3434
this.stackHeaders.authorization = this.management_token
35+
delete this.management_token
3536
}
36-
delete this.management_token
3737
/**
3838
* @description The Update stack call lets you update the name and description of an existing stack.
3939
* @memberof Stack
@@ -327,7 +327,7 @@ export function Stack (http, data) {
327327
* '{{env_name}}/env_uid}}'
328328
* ]
329329
* }
330-
* client.stack({ api_key: 'api_key'}).publish({ details: publishDetails })
330+
* client.stack({ api_key: 'api_key'}).bulkOperation().publish({ details: publishDetails })
331331
* .then((notice) => { console.log(notice) })
332332
*
333333
*/

lib/stack/roles/index.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -134,12 +134,15 @@ export function Role (http, data) {
134134
* .then((collection) => console.log(collection))
135135
*/
136136
this.fetchAll = async (params = {}) => {
137-
const headers = {
138-
params: { ...cloneDeep(params) },
139-
headers: {
140-
...cloneDeep(this.stackHeaders)
137+
const headers = {}
138+
if (this.stackHeaders) {
139+
headers.headers = this.stackHeaders
140+
}
141+
if (params) {
142+
headers.params = {
143+
...cloneDeep(params)
141144
}
142-
} || {}
145+
}
143146
try {
144147
const response = await http.get(this.urlPath, headers)
145148
if (response.data) {
@@ -173,7 +176,7 @@ export function Role (http, data) {
173176
}
174177

175178
export function RoleCollection (http, data) {
176-
const obj = cloneDeep(data.roles)
179+
const obj = cloneDeep(data.roles || [])
177180
const roleCollection = obj.map((userdata) => {
178181
return new Role(http, { role: userdata, stackHeaders: data.stackHeaders })
179182
})

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@
2424
"buildreactnative": "webpack --config webpack/webpack.react-native.js --mode production",
2525
"buildnativescript": "webpack --config webpack/webpack.nativescript.js --mode production",
2626
"buildweb": "webpack --config webpack/webpack.web.js --mode production",
27-
"test": "BABEL_ENV=test nyc --reporter=html --reporter=text mocha --require @babel/register ./test/test.js -t 30000 --reporter mochawesome --require babel-polyfill",
27+
"test": "npm run test:api && npm run test:unit",
28+
"test:api": "BABEL_ENV=test nyc --reporter=html --reporter=text mocha --require @babel/register ./test/test.js -t 30000 --reporter mochawesome --require babel-polyfill",
29+
"test:unit": "BABEL_ENV=test nyc --reporter=html --reporter=text mocha --require @babel/register ./test/unit/index.js -t 30000 --reporter mochawesome --require babel-polyfill",
2830
"test:debug": "BABEL_ENV=test mocha debug --require @babel/register ./test",
2931
"lint": "eslint lib test",
3032
"format": "eslint --fix lib test",

0 commit comments

Comments
 (0)