@@ -9,22 +9,28 @@ const testUser = {
9
9
location : {
10
10
name : 'Valhalla' ,
11
11
centre : 'Nairobi' ,
12
- country : 'Kenya' ,
13
- } ,
12
+ country : 'Kenya'
13
+ }
14
14
} ;
15
15
16
16
const newUser = {
17
17
...testUser ,
18
18
19
- username : 'Oliver Brice' ,
19
+ username : 'Oliver Brice'
20
+ } ;
21
+
22
+ const newUserCaps = {
23
+ ...testUser ,
24
+
25
+ username : 'Oliver Brice'
20
26
} ;
21
27
22
28
jest . mock ( 'nodemailer' , ( ) => ( {
23
29
createTransport : ( ) => ( {
24
30
sendMail : ( options , call ) => {
25
31
call ( ) ;
26
- } ,
27
- } ) ,
32
+ }
33
+ } )
28
34
} ) ) ;
29
35
30
36
jest . mock ( 'axios' , ( ) => ( {
@@ -33,10 +39,10 @@ jest.mock('axios', () => ({
33
39
get : ( ) => ( {
34
40
data : {
35
41
values : [ { } ] ,
36
- total : 1 ,
37
- } ,
38
- } ) ,
39
- } ) ,
42
+ total : 1
43
+ }
44
+ } )
45
+ } )
40
46
} ) ) ;
41
47
42
48
describe ( 'User tests' , ( ) => {
@@ -56,6 +62,15 @@ describe('User tests', () => {
56
62
} ) ;
57
63
} ) ;
58
64
65
+ it ( 'should normalize email' , done => {
66
+ sendRequest ( 'post' , '/api/users' , newUser , ( ) => {
67
+ sendRequest ( 'post' , '/api/users' , newUserCaps , ( err , res ) => {
68
+ expect ( res . text ) . toMatch ( 'email must be unique' ) ;
69
+ done ( ) ;
70
+ } ) ;
71
+ } ) ;
72
+ } ) ;
73
+
59
74
it ( 'should login an authorised user' , done => {
60
75
sendRequest (
61
76
'post' ,
@@ -139,7 +154,7 @@ describe('User tests', () => {
139
154
{
140
155
141
156
roleId : 3 ,
142
- locationId : 'cjee24cz40000guxs6bdner6l' ,
157
+ locationId : 'cjee24cz40000guxs6bdner6l'
143
158
} ,
144
159
( err , res ) => {
145
160
expect ( res . body . data . username ) . toEqual ( 'Oliver Munala' ) ;
@@ -155,7 +170,7 @@ describe('User tests', () => {
155
170
{
156
171
157
172
roleId : 3 ,
158
- locationId : 'cjee24cz40000guxs6bdner6l' ,
173
+ locationId : 'cjee24cz40000guxs6bdner6l'
159
174
} ,
160
175
( err , res ) => {
161
176
expect ( res . body . message ) . toMatch (
@@ -173,7 +188,7 @@ describe('User tests', () => {
173
188
{
174
189
175
190
roleId : 3 ,
176
- locationId : 'cjee24cz40000guxs6bdner6l' ,
191
+ locationId : 'cjee24cz40000guxs6bdner6l'
177
192
} ,
178
193
( err , res ) => {
179
194
expect ( res . body . message ) . toMatch (
@@ -191,7 +206,7 @@ describe('User tests', () => {
191
206
{
192
207
193
208
roleId : 1 ,
194
- locationId : 'cjee24n0n0000hfxsefer9tjh' ,
209
+ locationId : 'cjee24n0n0000hfxsefer9tjh'
195
210
} ,
196
211
( err , res ) => {
197
212
expect ( res . body . data . username ) . toEqual ( 'Batian Sss' ) ;
0 commit comments