-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathapp.test.js
41 lines (38 loc) · 1.15 KB
/
app.test.js
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
35
36
37
38
39
40
41
// These are mainly integration tests as openapi-mock mainly exists as an integration of external tools
const request = require('supertest');
const express = require('express');
const initapp = require('./app');
const assert = require('assert');
describe('app', () => {
let app;
before(async() => {
app = await initapp({
mock: './example/mocks'
});
});
after(() => {app.close()});
it('should return Content-Type=json for a valid api request', done => {
request(app)
.get('/v2/store/order/1')
.expect('Content-Type', /json/)
.expect(200, done)//TODO: remove?
});
it('should return status 200 for a valid api request', done => {
request(app)
.get('/v2/store/order/1')
.expect(200, done)
});
it('should return a generated response matching spec for endpoints without an example', done => {
request(app)
.get('/v2/pet/1')
.expect(res => {
// TODO: full spec check
assert.ok(res.body.name.length > 0)
})
.expect(200, done)
});
it.skip('should return example JSON for endpoints with an example', done => {
console.error('TODO:');
assert.ok(false);
});
})