UNPKG

generator-express-no-stress

Version:

Awesome APIs with ExpressJS and OpenAPI/Swagger: Features automatic request validation, interactive api doc, and more.

41 lines (36 loc) 1 kB
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('<%= apiRoot %>/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('<%= apiRoot %>/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('<%= apiRoot %>/examples/2') .expect('Content-Type', /json/) .then(r => { expect(r.body) .to.be.an.an('object') .that.has.property('name') .equal('test'); })); });