mirror of
https://github.com/usatiuk/ustk-todolist.git
synced 2025-10-29 08:07:48 +01:00
refactor app.js
test not found routes
This commit is contained in:
37
tests/integration/root.test.js
Normal file
37
tests/integration/root.test.js
Normal file
@@ -0,0 +1,37 @@
|
||||
const server = require('../../app.js');
|
||||
|
||||
const request = require('supertest');
|
||||
const mongoose = require('mongoose');
|
||||
|
||||
afterAll(async () => {
|
||||
await mongoose.connection.dropDatabase();
|
||||
await mongoose.disconnect();
|
||||
await server.close();
|
||||
});
|
||||
|
||||
describe('Test not found', () => {
|
||||
test('respond not found with json', async () => {
|
||||
const response = await request(server)
|
||||
.get('/')
|
||||
.set('Accept', 'application/json')
|
||||
.expect(404)
|
||||
.expect('Content-Type', 'application/json; charset=utf-8');
|
||||
expect(response.body).toEqual({ error: 'Not found' });
|
||||
});
|
||||
test('respond not found with html', async () => {
|
||||
const response = await request(server)
|
||||
.get('/')
|
||||
.set('Accept', 'text/html')
|
||||
.expect(404)
|
||||
.expect('Content-Type', 'text/html; charset=utf-8');
|
||||
expect(response.text).toEqual('404');
|
||||
});
|
||||
test('respond not found with plain text', async () => {
|
||||
const response = await request(server)
|
||||
.get('/')
|
||||
.set('Accept', 'text/plain')
|
||||
.expect(404)
|
||||
.expect('Content-Type', 'text/plain; charset=utf-8');
|
||||
expect(response.text).toEqual('not found');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user