Complete Users endpoints tests

This commit is contained in:
ruihildt 2019-08-02 01:47:48 +02:00
parent 33d5817e44
commit cdb89b275e
2 changed files with 47 additions and 18 deletions

Binary file not shown.

View File

@ -22,24 +22,53 @@ describe('Users.addUser', () => {
let users = await Users.findUserById(2); let users = await Users.findUserById(2);
expect(users.username).toBe('gabetest2'); expect(users.username).toBe('gabetest2');
}); });
// it('is only able to insert user as a string', async () => {
// let users = await Users.addUser({ username: 13 });
// let user = await Users.findUserById(1);
// expect(user.name).toBe('13');
// });
}); });
// describe('Users.remove', () => { describe('Users.removeUser', () => {
// it('is able to remove an user', async () => { it('is able to remove an user', async () => {
// await Users.insert({ name: 'dragon' }); await Users.addUser({
// await Users.insert({ name: 'phoenix' }); email: "gabetest@ls.com",
// let users = await Users.get(); username: "gabetest",
password: "1234"
});
await Users.addUser({
email: "gabetest2@ls.com",
username: "gabetest2",
password: "1234"
});
await Users.findUserById(2);
// users = await Users.remove(2); await Users.removeUser(2);
// users = await Users.get(); let userDel2 = await Users.findUserById(2);
// expect(users).toHaveLength(1); expect(userDel2).toBeUndefined();
// expect(users[0].name).toBe('dragon');
// }); let user1 = await Users.findUserById(1);
// }); expect(user1.username).toBe('gabetest');
await Users.removeUser(1);
let userDel = await Users.findUserById(1);
expect(userDel).toBeUndefined();
});
});
describe('Users.updateUser', () => {
it('is able to update a user', async () => {
await Users.addUser({
email: "gabetest@ls.com",
username: "gabetest",
password: "1234"
});
let user = await Users.findUserById(1);
expect(user.username).toBe('gabetest');
await Users.updateUser(1, {
email: "gabetest@ls.com",
username: "gabetestChanged",
password: "1234"
});
let updatedUser = await Users.findUserById(1);
expect(updatedUser.username).toBe('gabetestChanged');
});
});