Hospital-Management-System/server/test/examples.controller.js

39 lines
966 B
JavaScript
Raw Normal View History

2021-03-31 01:50:36 +00:00
import chai from 'chai';
import request from 'supertest';
import Server from '../server';
const expect = chai.expect;
describe('Examples', () => {
it('should get all examples', () =>
request(Server)
.get('/api/v1/examples')
.expect('Content-Type', /json/)
.then((r) => {
expect(r.body).to.be.an.an('array').of.length(2);
}));
it('should add a new example', () =>
request(Server)
.post('/api/v1/examples')
.send({ name: 'test' })
.expect('Content-Type', /json/)
.then((r) => {
expect(r.body)
.to.be.an.an('object')
.that.has.property('name')
.equal('test');
}));
it('should get an example by id', () =>
request(Server)
.get('/api/v1/examples/2')
.expect('Content-Type', /json/)
.then((r) => {
expect(r.body)
.to.be.an.an('object')
.that.has.property('name')
.equal('test');
}));
});