Complete Users endpoints tests
This commit is contained in:
parent
33d5817e44
commit
cdb89b275e
BIN
data/test.db3
BIN
data/test.db3
Binary file not shown.
@ -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');
|
||||||
|
});
|
||||||
|
});
|
Loading…
Reference in New Issue
Block a user