-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathserver.spec.js
More file actions
30 lines (21 loc) · 824 Bytes
/
server.spec.js
File metadata and controls
30 lines (21 loc) · 824 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
28
29
30
const request = require('supertest');
const server = require('./server');
describe('server.js', () => {
//http calls with supertest return promises, we can use async/await here
describe('index route', () => {
it ('should return a 200 status from the index route', async () => {
const expectedStatusCode = 200;
const response = await request(server).get('/');
expect(response.status).toEqual(expectedStatusCode);
});
it('should return an html element', async () => {
const response = await request(server).get('/');
expect(response.type).toEqual("text/html");
});
it('should return a string, "It\'s alive!"', async (done) => {
const expectedString = "It's alive!";
const response = await request(server).get('/');
expect(response.text).toEqual(expectedString),done();
});
})
})