-
Notifications
You must be signed in to change notification settings - Fork 0
/
password.test.js
50 lines (48 loc) · 1.6 KB
/
password.test.js
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
44
45
46
47
48
49
50
const {badhanAxios} = require('../../api');
const validate = require('jsonschema').validate;
const env = require('../../config');
const {processError}=require('../fixtures/helpers');
const patchPasswordSchema={
type: "object",
additionalProperties: false,
properties: {
status: {type: "string"},
statusCode: {const: 201},
message: {type: "string"},
token: {type: "string"}
},
required: ["status", "statusCode", "token", "message"]
}
test('PATCH/users/password', async () => {
try {
let signInResponse = await badhanAxios.post('/users/signin', {
phone: env.SUPERADMIN_PHONE,
password: env.SUPERADMIN_PASSWORD
});
let passwordResponse = await badhanAxios.patch("/users/password", {
"password": env.SUPERADMIN_PASSWORD
}, {
headers: {
"x-auth": signInResponse.data.token
}
});
let validationResult = validate(passwordResponse.data, patchPasswordSchema);
expect(validationResult.errors).toEqual([]);
await badhanAxios.delete('/users/signout', {
headers: {
"x-auth": passwordResponse.data.token
}
});
}catch (e) {
throw processError(e);
}
})
test('PATCH/guest/users/password', async () => {
try {
let passwordResponse = await badhanAxios.patch("/guest/users/password");
let validationResult = validate(passwordResponse.data, patchPasswordSchema);
expect(validationResult.errors).toEqual([]);
}catch (e) {
throw processError(e);
}
})