45 lines
1.1 KiB
JavaScript
45 lines
1.1 KiB
JavaScript
const db = require('../../data/dbConfig');
|
|
const Users = require('./usersModel');
|
|
|
|
beforeEach(async () => {
|
|
await db('users').truncate();
|
|
});
|
|
|
|
describe('Users.addUser', () => {
|
|
|
|
it('is able to insert user to the db', async () => {
|
|
await Users.addUser({
|
|
email: "gabetest@ls.com",
|
|
username: "gabetest",
|
|
password: "1234"
|
|
});
|
|
await Users.addUser({
|
|
email: "gabetest2@ls.com",
|
|
username: "gabetest2",
|
|
password: "1234"
|
|
});
|
|
|
|
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();
|
|
|
|
// users = await Users.remove(2);
|
|
// users = await Users.get();
|
|
// expect(users).toHaveLength(1);
|
|
// expect(users[0].name).toBe('dragon');
|
|
// });
|
|
// });
|