Last active
January 30, 2019 13:47
-
-
Save hypeJunction/18200ce8c42b396d9c75e606166b5fd0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import request from 'supertest'; | |
// Factory allows us to produce a "clean" instance of an app | |
// with stubbed services for each test | |
import factory from '../factory'; | |
describe('AccountController', () => { | |
let app; | |
let services; | |
let models; | |
beforeEach(async () => { | |
app = await factory(); | |
services = app.get('services'); | |
models = services.db.models; | |
}); | |
afterEach(() => { | |
app = null; | |
services = null; | |
models = null; | |
}); | |
describe('.login()', async () => { | |
it('should fail login with invalid credentials', async () => { | |
const password = 'abcdefgh123456'; | |
const user = await services.seeder.user({ | |
password, | |
}); | |
const response = await request(app) | |
.post('/api/account/login') | |
.send({ | |
email: user.email, | |
password: '1234567', | |
}) | |
.set('Accept', 'application/json'); | |
expect(response.statusCode).to.equal(403); | |
// We can then test expected side-effects and state changes, | |
// for example we could grab the logger service and | |
// make sure a corresponding entry was made | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment