tests: Asyncify tests in `api.js`
parent
e0f499cf5a
commit
71c1899164
|
@ -32,20 +32,19 @@ const endPoint = (point) => `/api/${apiVersion}/${point}?apikey=${apiKey}`;
|
||||||
describe(__filename, function () {
|
describe(__filename, function () {
|
||||||
before(async function () { agent = await common.init(); });
|
before(async function () { agent = await common.init(); });
|
||||||
|
|
||||||
it('can obtain API version', function (done) {
|
it('can obtain API version', async function () {
|
||||||
agent
|
await agent.get('/api/')
|
||||||
.get('/api/')
|
.expect(200)
|
||||||
.expect((res) => {
|
.expect((res) => {
|
||||||
apiVersion = res.body.currentVersion;
|
apiVersion = res.body.currentVersion;
|
||||||
if (!res.body.currentVersion) throw new Error('No version set in API');
|
if (!res.body.currentVersion) throw new Error('No version set in API');
|
||||||
return;
|
return;
|
||||||
})
|
});
|
||||||
.expect(200, done);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('can obtain valid openapi definition document', function (done) {
|
it('can obtain valid openapi definition document', async function () {
|
||||||
agent
|
await agent.get('/api/openapi.json')
|
||||||
.get('/api/openapi.json')
|
.expect(200)
|
||||||
.expect((res) => {
|
.expect((res) => {
|
||||||
const {valid, errors} = validateOpenAPI(res.body, 3);
|
const {valid, errors} = validateOpenAPI(res.body, 3);
|
||||||
if (!valid) {
|
if (!valid) {
|
||||||
|
@ -53,18 +52,15 @@ describe(__filename, function () {
|
||||||
throw new Error(`Document is not valid OpenAPI. ${errors.length} ` +
|
throw new Error(`Document is not valid OpenAPI. ${errors.length} ` +
|
||||||
`validation errors:\n${prettyErrors}`);
|
`validation errors:\n${prettyErrors}`);
|
||||||
}
|
}
|
||||||
return;
|
});
|
||||||
})
|
|
||||||
.expect(200, done);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('supports jsonp calls', function (done) {
|
it('supports jsonp calls', async function () {
|
||||||
agent
|
await agent.get(`${endPoint('createPad')}&jsonp=jsonp_1&padID=${testPadId}`)
|
||||||
.get(`${endPoint('createPad')}&jsonp=jsonp_1&padID=${testPadId}`)
|
.expect(200)
|
||||||
|
.expect('Content-Type', /javascript/)
|
||||||
.expect((res) => {
|
.expect((res) => {
|
||||||
if (!res.text.match('jsonp_1')) throw new Error('no jsonp call seen');
|
if (!res.text.match('jsonp_1')) throw new Error('no jsonp call seen');
|
||||||
})
|
});
|
||||||
.expect('Content-Type', /javascript/)
|
|
||||||
.expect(200, done);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue