Skip to content

Commit 2ced68d

Browse files
authoredNov 6, 2020
Add support for query params for getRoles method (#530)
* feat(roles): add tests feat(roles): adjust tests * feat(roles): add query options for getRoles
1 parent 4f29cd7 commit 2ced68d

File tree

2 files changed

+29
-3
lines changed

2 files changed

+29
-3
lines changed
 

‎lib/create-space-api.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -995,9 +995,10 @@ export default function createSpaceApi({
995995
* .catch(console.error)
996996
* ```
997997
*/
998-
getRoles() {
998+
getRoles(query: QueryOptions = {}) {
999+
normalizeSelect(query)
9991000
return http
1000-
.get('roles')
1001+
.get('roles', createRequestConfig({ query }))
10011002
.then((response) => wrapRoleCollection(http, response.data), errorHandler)
10021003
},
10031004

‎test/integration/role-integration.js

+26-1
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,38 @@ const roleDefinition = {
2020

2121
export default function roleTests(t, space) {
2222
t.test('Gets roles', (t) => {
23-
t.plan(2)
23+
t.plan(3)
2424
return space.getRoles().then((response) => {
2525
t.ok(response.sys, 'sys')
2626
t.ok(response.items, 'fields')
27+
t.equal(response.items.length, 4)
2728
})
2829
})
2930

31+
t.test('Gets roles with a limit parameter', (t) => {
32+
t.plan(2)
33+
return space
34+
.getRoles({
35+
limit: 2,
36+
})
37+
.then((response) => {
38+
t.ok(response.items, 'items')
39+
t.equal(response.items.length, 2)
40+
})
41+
})
42+
43+
t.test('Gets roles with skip parameter', (t) => {
44+
t.plan(2)
45+
return space
46+
.getRoles({
47+
skip: 2,
48+
})
49+
.then((response) => {
50+
t.ok(response.items, 'items')
51+
t.equal(response.skip, 2)
52+
})
53+
})
54+
3055
t.test('Create role with id', (t) => {
3156
const id = generateRandomId('role')
3257
return space.createRoleWithId(id, roleDefinition).then((role) => {

0 commit comments

Comments
 (0)
Please sign in to comment.