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);
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', () => {
// it('is able to remove an user', async () => {
// await Users.insert({ name: 'dragon' });
// await Users.insert({ name: 'phoenix' });
// let users = await Users.get();
describe('Users.removeUser', () => {
it('is able to remove an user', async () => {
await Users.addUser({
email: "gabetest@ls.com",
username: "gabetest",
password: "1234"
});
await Users.addUser({
email: "gabetest2@ls.com",
username: "gabetest2",
password: "1234"
});
await Users.findUserById(2);
// users = await Users.remove(2);
// users = await Users.get();
// expect(users).toHaveLength(1);
// expect(users[0].name).toBe('dragon');
// });
// });
await Users.removeUser(2);
let userDel2 = await Users.findUserById(2);
expect(userDel2).toBeUndefined();
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');
});
});