-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain_test.js
More file actions
35 lines (30 loc) · 1.05 KB
/
main_test.js
File metadata and controls
35 lines (30 loc) · 1.05 KB
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
31
32
33
34
const chai = require('chai');
const chaiHttp = require('chai-http');
const expect = chai.expect;
const app = require('./main');
chai.use(chaiHttp);
describe('Express app', () => {
// Test the "/" endpoint
describe('GET /', () => {
it('should return all data', async () => {
const res = await chai.request(app).get('/');
expect(res.status).to.equal(200);
expect(res.body).to.be.an('array');
});
});
// Test the "//:guid" endpoint
describe('GET /:guid', () => {
it('should return a single item of data', async () => {
const res =
await chai.request(app).get('/05024756-765e-41a9-89d7-1407436d9a58');
expect(res.status).to.equal(200);
expect(res.body).to.be.an('object');
expect(res.body.guid).to.equal('05024756-765e-41a9-89d7-1407436d9a58');
});
it('should return a 404 status code for an invalid GUID', async () => {
const res = await chai.request(app).get('/invalid-guid');
expect(res.status).to.equal(404);
expect(res.text).to.equal('Item not found');
});
});
});