generated from ministryofjustice/hmpps-template-typescript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
manageUsersApi.ts
43 lines (39 loc) · 926 Bytes
/
manageUsersApi.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import { Response } from 'superagent'
import { stubFor } from './wiremock'
const stubUser = (name: string) =>
stubFor({
request: {
method: 'GET',
urlPattern: '/manage-users-api/users/me',
},
response: {
status: 200,
headers: {
'Content-Type': 'application/json;charset=UTF-8',
},
jsonBody: {
staffId: 231232,
username: 'USER1',
active: true,
name,
},
},
})
const stubUserRoles = () =>
stubFor({
request: {
method: 'GET',
urlPattern: '/manage-users-api/users/me/roles',
},
response: {
status: 200,
headers: {
'Content-Type': 'application/json;charset=UTF-8',
},
jsonBody: [{ roleCode: 'SOME_USER_ROLE' }],
},
})
export default {
stubManageUser: (name = 'john smith'): Promise<[Response, Response]> =>
Promise.all([stubUser(name), stubUserRoles()]),
}