UNPKG

generator-express-no-stress

Version:

Awesome APIs with ExpressJS and OpenAPI 3 (or Swagger 2): Features automatic request/resopnse validation, interactive api doc, and more.

39 lines (35 loc) 989 B
import { expect } from 'chai'; import request from 'supertest'; import Server from '../server/index.js'; 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'); })); });