tests: Delete unnecessary `describe()` calls in `api.js`
parent
fc9b22475a
commit
08124ba733
|
@ -32,45 +32,39 @@ const testPadId = makeid();
|
||||||
const endPoint = (point) => `/api/${apiVersion}/${point}?apikey=${apiKey}`;
|
const endPoint = (point) => `/api/${apiVersion}/${point}?apikey=${apiKey}`;
|
||||||
|
|
||||||
describe(__filename, function () {
|
describe(__filename, function () {
|
||||||
describe('API Versioning', function () {
|
it('can obtain API version', function (done) {
|
||||||
it('errors if can not connect', function (done) {
|
api
|
||||||
api
|
.get('/api/')
|
||||||
.get('/api/')
|
.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);
|
||||||
.expect(200, done);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('OpenAPI definition', function () {
|
it('can obtain valid openapi definition document', function (done) {
|
||||||
it('generates valid openapi definition document', function (done) {
|
api
|
||||||
api
|
.get('/api/openapi.json')
|
||||||
.get('/api/openapi.json')
|
.expect((res) => {
|
||||||
.expect((res) => {
|
const {valid, errors} = validateOpenAPI(res.body, 3);
|
||||||
const {valid, errors} = validateOpenAPI(res.body, 3);
|
if (!valid) {
|
||||||
if (!valid) {
|
const prettyErrors = JSON.stringify(errors, null, 2);
|
||||||
const prettyErrors = JSON.stringify(errors, null, 2);
|
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;
|
||||||
return;
|
})
|
||||||
})
|
.expect(200, done);
|
||||||
.expect(200, done);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('jsonp support', function () {
|
it('supports jsonp calls', function (done) {
|
||||||
it('supports jsonp calls', function (done) {
|
api
|
||||||
api
|
.get(`${endPoint('createPad')}&jsonp=jsonp_1&padID=${testPadId}`)
|
||||||
.get(`${endPoint('createPad')}&jsonp=jsonp_1&padID=${testPadId}`)
|
.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('Content-Type', /javascript/)
|
.expect(200, done);
|
||||||
.expect(200, done);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue