-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapp.test.js
More file actions
27 lines (23 loc) · 830 Bytes
/
app.test.js
File metadata and controls
27 lines (23 loc) · 830 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
const request = require('supertest');
const { app, server } = require('./app');
describe('Basic Route Tests', () => {
test('GET / should return 200', async () => {
const response = await request(app).get('/');
expect(response.statusCode).toBe(200);
});
test('GET /debug should return JSON', async () => {
const response = await request(app).get('/debug');
expect(response.statusCode).toBe(200);
expect(response.type).toBe('application/json');
});
test('POST /login with correct credentials should succeed', async () => {
const response = await request(app)
.post('/login')
.send({ username: 'admin', password: 'secretpassword' });
expect(response.statusCode).toBe(200);
expect(response.body.success).toBe(true);
});
afterAll(done => {
server.close(done);
});
});