-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- normalizes email upon signup [Delivers #167975800]
- Loading branch information
1 parent
7c63683
commit 2029fba
Showing
2 changed files
with
32 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,22 +9,28 @@ const testUser = { | |
location: { | ||
name: 'Valhalla', | ||
centre: 'Nairobi', | ||
country: 'Kenya', | ||
}, | ||
country: 'Kenya' | ||
} | ||
}; | ||
|
||
const newUser = { | ||
...testUser, | ||
email: '[email protected]', | ||
username: 'Oliver Brice', | ||
username: 'Oliver Brice' | ||
}; | ||
|
||
const newUserCaps = { | ||
...testUser, | ||
email: '[email protected]', | ||
username: 'Oliver Brice' | ||
}; | ||
|
||
jest.mock('nodemailer', () => ({ | ||
createTransport: () => ({ | ||
sendMail: (options, call) => { | ||
call(); | ||
}, | ||
}), | ||
} | ||
}) | ||
})); | ||
|
||
jest.mock('axios', () => ({ | ||
|
@@ -33,10 +39,10 @@ jest.mock('axios', () => ({ | |
get: () => ({ | ||
data: { | ||
values: [{}], | ||
total: 1, | ||
}, | ||
}), | ||
}), | ||
total: 1 | ||
} | ||
}) | ||
}) | ||
})); | ||
|
||
describe('User tests', () => { | ||
|
@@ -56,6 +62,15 @@ describe('User tests', () => { | |
}); | ||
}); | ||
|
||
it('should normalize email', done => { | ||
sendRequest('post', '/api/users', newUser, () => { | ||
sendRequest('post', '/api/users', newUserCaps, (err, res) => { | ||
expect(res.text).toMatch('email must be unique'); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
|
||
it('should login an authorised user', done => { | ||
sendRequest( | ||
'post', | ||
|
@@ -139,7 +154,7 @@ describe('User tests', () => { | |
{ | ||
email: '[email protected]', | ||
roleId: 3, | ||
locationId: 'cjee24cz40000guxs6bdner6l', | ||
locationId: 'cjee24cz40000guxs6bdner6l' | ||
}, | ||
(err, res) => { | ||
expect(res.body.data.username).toEqual('Oliver Munala'); | ||
|
@@ -155,7 +170,7 @@ describe('User tests', () => { | |
{ | ||
email: '[email protected]', | ||
roleId: 3, | ||
locationId: 'cjee24cz40000guxs6bdner6l', | ||
locationId: 'cjee24cz40000guxs6bdner6l' | ||
}, | ||
(err, res) => { | ||
expect(res.body.message).toMatch( | ||
|
@@ -173,7 +188,7 @@ describe('User tests', () => { | |
{ | ||
email: '[email protected]', | ||
roleId: 3, | ||
locationId: 'cjee24cz40000guxs6bdner6l', | ||
locationId: 'cjee24cz40000guxs6bdner6l' | ||
}, | ||
(err, res) => { | ||
expect(res.body.message).toMatch( | ||
|
@@ -191,7 +206,7 @@ describe('User tests', () => { | |
{ | ||
email: '[email protected]', | ||
roleId: 1, | ||
locationId: 'cjee24n0n0000hfxsefer9tjh', | ||
locationId: 'cjee24n0n0000hfxsefer9tjh' | ||
}, | ||
(err, res) => { | ||
expect(res.body.data.username).toEqual('Batian Sss'); | ||
|