From 3a9cb31e1f6039aecd428b2fc250b4b88a18ccfa Mon Sep 17 00:00:00 2001 From: kachulio1 Date: Thu, 3 Jan 2019 20:29:37 +0300 Subject: [PATCH] add afterAll to make CI pass --- src/graphql-schema.test.js | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/graphql-schema.test.js b/src/graphql-schema.test.js index 4956c3ab0..f8207ffa5 100644 --- a/src/graphql-schema.test.js +++ b/src/graphql-schema.test.js @@ -8,15 +8,17 @@ let getHost let app let port -beforeEach(async () => { +beforeEach(async (done) => { const server = createServer({ mocks }) app = await server.start({ port: 0 }) port = app.address().port getHost = () => `http://127.0.0.1:${port}` + done() }) -afterEach(async () => { +afterAll(async (done) => { await app.close() + done() }) describe.only('login', () => { @@ -31,45 +33,50 @@ describe.only('login', () => { } describe('given an existing user', () => { - beforeEach(async () => { + beforeEach(async (done) => { await create('user', { email: 'test@example.org', password: '1234' }) + done() }) - afterEach(async () => { + afterEach(async (done) => { await cleanDatabase() + done() }) describe('asking for a `token`', () => { describe('with valid email/password combination', () => { - it('responds with a JWT token', async () => { + it('responds with a JWT token', async (done) => { const data = await request(getHost(), mutation({ email: 'test@example.org', password: '1234' })) const { token } = data.login jwt.verify(token, process.env.JWT_SECRET, (err, data) => { expect(data.email).toEqual('test@example.org') expect(err).toBeNull() + done() }) }) }) describe('with a valid email but incorrect password', () => { - it('responds with "Incorrect email address or password."', async () => { + it('responds with "Incorrect email address or password."', async (done) => { try { await request(getHost(), mutation({ email: 'test@example.org', password: 'wrong' })) } catch (error) { expect(error.response.errors[0].message).toEqual('Incorrect email address or password.') + done() } }) }) describe('with a non-existing email', () => { - it('responds with "Incorrect email address or password."', async () => { + it('responds with "Incorrect email address or password."', async (doen) => { try { await request(getHost(), mutation({ email: 'non-existent@example.org', password: 'wrong' })) } catch (error) { expect(error.response.errors[0].message).toEqual('Incorrect email address or password.') + done() } }) })