2019-03-24 02:10:00 +01:00
|
|
|
import request from 'supertest'
|
2019-04-12 16:26:13 +02:00
|
|
|
import server from '../src/server'
|
2019-03-24 02:10:00 +01:00
|
|
|
import {} from 'jasmine'
|
2019-03-07 14:41:27 +01:00
|
|
|
|
2019-03-24 02:10:00 +01:00
|
|
|
afterAll(done => {
|
|
|
|
server.close(done)
|
|
|
|
})
|
2019-03-07 14:41:27 +01:00
|
|
|
|
2019-03-24 02:10:00 +01:00
|
|
|
describe('POST /api/v1/urlcheck', () => {
|
2019-04-30 19:19:28 +02:00
|
|
|
it('responds with json', async () => {
|
|
|
|
const response = await request(server).post('/api/v1/urlcheck')
|
|
|
|
expect(response.statusCode).toBe(200)
|
|
|
|
})
|
|
|
|
|
|
|
|
it('responds with error message when url is missing', async () => {
|
|
|
|
const response = await request(server).post('/api/v1/urlcheck')
|
|
|
|
const text = await JSON.parse(response.text)
|
|
|
|
expect(text.message).toBe('missing url')
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
describe('Errors', () => {
|
|
|
|
it('responds with 404 on unknown path', async () => {
|
|
|
|
const response = await request(server).post('/whatever')
|
|
|
|
expect(response.statusCode).toBe(404)
|
2019-03-24 02:10:00 +01:00
|
|
|
})
|
|
|
|
})
|