2021-04-24 16:03:27 +00:00
|
|
|
import request from 'supertest'
|
|
|
|
import { app } from '../app'
|
|
|
|
|
|
|
|
describe('root path requests', () => {
|
2021-05-13 19:29:37 +00:00
|
|
|
it('responds 200 to the GET method', async () => {
|
2021-04-24 16:03:27 +00:00
|
|
|
const result = await request(app).get('/').send()
|
|
|
|
|
|
|
|
expect(result.status).toBe(200)
|
|
|
|
})
|
|
|
|
|
2021-05-13 19:29:37 +00:00
|
|
|
it('responds 404 to the POST method', async () => {
|
2021-04-24 16:03:27 +00:00
|
|
|
const result = await request(app).post('/').send()
|
|
|
|
|
|
|
|
expect(result.status).toBe(404)
|
|
|
|
})
|
|
|
|
|
2021-05-13 19:29:37 +00:00
|
|
|
it('responds 404 to the PATCH method', async () => {
|
2021-04-24 16:03:27 +00:00
|
|
|
const result = await request(app).patch('/').send()
|
|
|
|
|
|
|
|
expect(result.status).toBe(404)
|
|
|
|
})
|
|
|
|
|
2021-05-13 19:29:37 +00:00
|
|
|
it('responds 404 to the DELETE method', async () => {
|
2021-04-24 16:03:27 +00:00
|
|
|
const result = await request(app).delete('/').send()
|
|
|
|
|
|
|
|
expect(result.status).toBe(404)
|
|
|
|
})
|
2021-05-13 19:29:37 +00:00
|
|
|
|
|
|
|
it('redirects to root when a non existing server route is requested', async () => {
|
|
|
|
const result = await request(app).get('/settings').send()
|
|
|
|
|
|
|
|
expect(result.header.location).toBe('/')
|
|
|
|
expect(result.status).toBe(302)
|
|
|
|
})
|
2021-04-24 16:03:27 +00:00
|
|
|
})
|