mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2025-12-13 07:45:56 +00:00
Revert "add afterAll to make CI pass"
This reverts commit 3a9cb31e1f6039aecd428b2fc250b4b88a18ccfa. See https://github.com/Human-Connection/Nitro-Backend/pull/88#discussion_r245157595
This commit is contained in:
parent
e1070e15f2
commit
96d9bb49bc
@ -8,17 +8,15 @@ let getHost
|
|||||||
let app
|
let app
|
||||||
let port
|
let port
|
||||||
|
|
||||||
beforeEach(async (done) => {
|
beforeEach(async () => {
|
||||||
const server = createServer({ mocks })
|
const server = createServer({ mocks })
|
||||||
app = await server.start({ port: 0 })
|
app = await server.start({ port: 0 })
|
||||||
port = app.address().port
|
port = app.address().port
|
||||||
getHost = () => `http://127.0.0.1:${port}`
|
getHost = () => `http://127.0.0.1:${port}`
|
||||||
done()
|
|
||||||
})
|
})
|
||||||
|
|
||||||
afterAll(async (done) => {
|
afterEach(async () => {
|
||||||
await app.close()
|
await app.close()
|
||||||
done()
|
|
||||||
})
|
})
|
||||||
|
|
||||||
describe.only('login', () => {
|
describe.only('login', () => {
|
||||||
@ -33,50 +31,45 @@ describe.only('login', () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
describe('given an existing user', () => {
|
describe('given an existing user', () => {
|
||||||
beforeEach(async (done) => {
|
beforeEach(async () => {
|
||||||
await create('user', {
|
await create('user', {
|
||||||
email: 'test@example.org',
|
email: 'test@example.org',
|
||||||
password: '1234'
|
password: '1234'
|
||||||
})
|
})
|
||||||
done()
|
|
||||||
})
|
})
|
||||||
|
|
||||||
afterEach(async (done) => {
|
afterEach(async () => {
|
||||||
await cleanDatabase()
|
await cleanDatabase()
|
||||||
done()
|
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('asking for a `token`', () => {
|
describe('asking for a `token`', () => {
|
||||||
describe('with valid email/password combination', () => {
|
describe('with valid email/password combination', () => {
|
||||||
it('responds with a JWT token', async (done) => {
|
it('responds with a JWT token', async () => {
|
||||||
const data = await request(getHost(), mutation({ email: 'test@example.org', password: '1234' }))
|
const data = await request(getHost(), mutation({ email: 'test@example.org', password: '1234' }))
|
||||||
const { token } = data.login
|
const { token } = data.login
|
||||||
jwt.verify(token, process.env.JWT_SECRET, (err, data) => {
|
jwt.verify(token, process.env.JWT_SECRET, (err, data) => {
|
||||||
expect(data.email).toEqual('test@example.org')
|
expect(data.email).toEqual('test@example.org')
|
||||||
expect(err).toBeNull()
|
expect(err).toBeNull()
|
||||||
done()
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('with a valid email but incorrect password', () => {
|
describe('with a valid email but incorrect password', () => {
|
||||||
it('responds with "Incorrect email address or password."', async (done) => {
|
it('responds with "Incorrect email address or password."', async () => {
|
||||||
try {
|
try {
|
||||||
await request(getHost(), mutation({ email: 'test@example.org', password: 'wrong' }))
|
await request(getHost(), mutation({ email: 'test@example.org', password: 'wrong' }))
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
expect(error.response.errors[0].message).toEqual('Incorrect email address or password.')
|
expect(error.response.errors[0].message).toEqual('Incorrect email address or password.')
|
||||||
done()
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('with a non-existing email', () => {
|
describe('with a non-existing email', () => {
|
||||||
it('responds with "Incorrect email address or password."', async (done) => {
|
it('responds with "Incorrect email address or password."', async () => {
|
||||||
try {
|
try {
|
||||||
await request(getHost(), mutation({ email: 'non-existent@example.org', password: 'wrong' }))
|
await request(getHost(), mutation({ email: 'non-existent@example.org', password: 'wrong' }))
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
expect(error.response.errors[0].message).toEqual('Incorrect email address or password.')
|
expect(error.response.errors[0].message).toEqual('Incorrect email address or password.')
|
||||||
done()
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user