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 () {
|
||||
before(async function () { agent = await common.init(); });
|
||||
|
||||
it('can obtain API version', function (done) {
|
||||
agent
|
||||
.get('/api/')
|
||||
it('can obtain API version', async function () {
|
||||
await agent.get('/api/')
|
||||
.expect(200)
|
||||
.expect((res) => {
|
||||
apiVersion = res.body.currentVersion;
|
||||
if (!res.body.currentVersion) throw new Error('No version set in API');
|
||||
return;
|
||||
})
|
||||
.expect(200, done);
|
||||
});
|
||||
});
|
||||
|
||||
it('can obtain valid openapi definition document', function (done) {
|
||||
agent
|
||||
.get('/api/openapi.json')
|
||||
it('can obtain valid openapi definition document', async function () {
|
||||
await agent.get('/api/openapi.json')
|
||||
.expect(200)
|
||||
.expect((res) => {
|
||||
const {valid, errors} = validateOpenAPI(res.body, 3);
|
||||
if (!valid) {
|
||||
|
@ -53,18 +52,15 @@ describe(__filename, function () {
|
|||
throw new Error(`Document is not valid OpenAPI. ${errors.length} ` +
|
||||
`validation errors:\n${prettyErrors}`);
|
||||
}
|
||||
return;
|
||||
})
|
||||
.expect(200, done);
|
||||
});
|
||||
});
|
||||
|
||||
it('supports jsonp calls', function (done) {
|
||||
agent
|
||||
.get(`${endPoint('createPad')}&jsonp=jsonp_1&padID=${testPadId}`)
|
||||
it('supports jsonp calls', async function () {
|
||||
await agent.get(`${endPoint('createPad')}&jsonp=jsonp_1&padID=${testPadId}`)
|
||||
.expect(200)
|
||||
.expect('Content-Type', /javascript/)
|
||||
.expect((res) => {
|
||||
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