Stricter when running test, now we wait until resetdatabase and createuser are done in in the before function before running the tests.

This commit is contained in:
2018-03-19 15:27:11 +01:00
parent 559ef1bc11
commit ed5d302820
2 changed files with 8 additions and 4 deletions

View File

@@ -5,8 +5,10 @@ const createUser = require('test/helpers/createUser');
const resetDatabase = require('test/helpers/resetDatabase');
describe('As a user I want to log in', () => {
before(() => resetDatabase());
before(() => createUser('test_user', 'test@gmail.com', 'password'));
before(() => {
return resetDatabase()
.then(() => createUser('test_user', 'password'))
})
it('should return 200 with a token if correct credentials are given', () =>
request(app)

View File

@@ -5,8 +5,10 @@ const createUser = require('test/helpers/createUser');
const createToken = require('test/helpers/createToken');
describe('As a user I want to request a movie', () => {
before(() => resetDatabase());
before(() => createUser('test_user', 'test@gmail.com', 'password'));
before(() => {
return resetDatabase()
.then(() => createUser('test_user', 'test@gmail.com', 'password'));
})
it('should return 200 when item is requested', () =>
request(app)