Skip to content

Commit b7b5aff

Browse files
committed
Test: update tests
1 parent c81fe99 commit b7b5aff

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

test/controllers/UserController.test.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@ test.serial('User | create', async (t) => {
2323
.post('/public/user')
2424
.set('Accept', /json/)
2525
.send({
26-
username: 'martin',
26+
email: 'martin@mail.com',
2727
password: 'securepassword',
28+
password2: 'securepassword',
2829
})
2930
.expect(200)
3031
.then((res) => {
@@ -35,15 +36,15 @@ test.serial('User | create', async (t) => {
3536

3637
await User.findById(id).then((user) => {
3738
t.is(user.id, id);
38-
t.is(user.username, 'martin');
39+
t.is(user.email, 'martin@mail.com');
3940
return user.destroy();
4041
});
4142
});
4243

4344
test.serial('User | login', async (t) => {
4445
let testUser;
4546
await User.create({
46-
username: 'martin',
47+
email: 'martin@mail.com',
4748
password: 'securepassword',
4849
}).then((user) => {
4950
testUser = user;
@@ -54,7 +55,7 @@ test.serial('User | login', async (t) => {
5455
.post('/public/login')
5556
.set('Accept', /json/)
5657
.send({
57-
username: 'martin',
58+
email: 'martin@mail.com',
5859
password: 'securepassword',
5960
})
6061
.expect(200)
@@ -69,7 +70,7 @@ test.serial('User | get all (auth)', async (t) => {
6970
let token;
7071
let testUser;
7172
await User.create({
72-
username: 'martin',
73+
email: 'martin@mail.com',
7374
password: 'securepassword',
7475
}).then((user) => {
7576
testUser = user;
@@ -80,7 +81,7 @@ test.serial('User | get all (auth)', async (t) => {
8081
.post('/public/login')
8182
.set('Accept', /json/)
8283
.send({
83-
username: 'martin',
84+
email: 'martin@mail.com',
8485
password: 'securepassword',
8586
})
8687
.expect(200)

test/models/User.test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const User = require('../../api/models/User');
33

44
test.beforeEach(async (t) => {
55
await User.create({ // eslint-disable-line
6-
username: 'martin',
6+
email: 'martin@mail.com',
77
password: 'securepassword',
88
}).then((user) => {
99
t.context.user = user; // eslint-disable-line
@@ -14,7 +14,7 @@ test.beforeEach(async (t) => {
1414
test.serial('User is created correctly', async (t) => {
1515
const sendUser = t.context.user.toJSON();
1616
// check if user is created
17-
t.is(t.context.user.username, 'martin');
17+
t.is(t.context.user.email, 'martin@mail.com');
1818
// check if password is not send to browser
1919
t.falsy(sendUser.password);
2020

@@ -23,13 +23,13 @@ test.serial('User is created correctly', async (t) => {
2323

2424
test.serial('User is updated correctly', async (t) => {
2525
await t.context.user.update({
26-
username: 'peter',
26+
email: 'peter@mail.com',
2727
}).then((user) => {
2828
t.context.user = user; // eslint-disable-line
2929
return t.context.user;
3030
});
3131

32-
t.is(t.context.user.username, 'peter');
32+
t.is(t.context.user.email, 'peter@mail.com');
3333

3434
await t.context.user.destroy();
3535
});

0 commit comments

Comments
 (0)