tests: Delete unnecessary describe()
calls in api.js
This commit is contained in:
parent
fc9b22475a
commit
08124ba733
1 changed files with 30 additions and 36 deletions
|
@ -32,45 +32,39 @@ const testPadId = makeid();
|
|||
const endPoint = (point) => `/api/${apiVersion}/${point}?apikey=${apiKey}`;
|
||||
|
||||
describe(__filename, function () {
|
||||
describe('API Versioning', function () {
|
||||
it('errors if can not connect', function (done) {
|
||||
api
|
||||
.get('/api/')
|
||||
.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 API version', function (done) {
|
||||
api
|
||||
.get('/api/')
|
||||
.expect((res) => {
|
||||
apiVersion = res.body.currentVersion;
|
||||
if (!res.body.currentVersion) throw new Error('No version set in API');
|
||||
return;
|
||||
})
|
||||
.expect(200, done);
|
||||
});
|
||||
|
||||
describe('OpenAPI definition', function () {
|
||||
it('generates valid openapi definition document', function (done) {
|
||||
api
|
||||
.get('/api/openapi.json')
|
||||
.expect((res) => {
|
||||
const {valid, errors} = validateOpenAPI(res.body, 3);
|
||||
if (!valid) {
|
||||
const prettyErrors = JSON.stringify(errors, null, 2);
|
||||
throw new Error(`Document is not valid OpenAPI. ${errors.length} ` +
|
||||
`validation errors:\n${prettyErrors}`);
|
||||
}
|
||||
return;
|
||||
})
|
||||
.expect(200, done);
|
||||
});
|
||||
it('can obtain valid openapi definition document', function (done) {
|
||||
api
|
||||
.get('/api/openapi.json')
|
||||
.expect((res) => {
|
||||
const {valid, errors} = validateOpenAPI(res.body, 3);
|
||||
if (!valid) {
|
||||
const prettyErrors = JSON.stringify(errors, null, 2);
|
||||
throw new Error(`Document is not valid OpenAPI. ${errors.length} ` +
|
||||
`validation errors:\n${prettyErrors}`);
|
||||
}
|
||||
return;
|
||||
})
|
||||
.expect(200, done);
|
||||
});
|
||||
|
||||
describe('jsonp support', function () {
|
||||
it('supports jsonp calls', function (done) {
|
||||
api
|
||||
.get(`${endPoint('createPad')}&jsonp=jsonp_1&padID=${testPadId}`)
|
||||
.expect((res) => {
|
||||
if (!res.text.match('jsonp_1')) throw new Error('no jsonp call seen');
|
||||
})
|
||||
.expect('Content-Type', /javascript/)
|
||||
.expect(200, done);
|
||||
});
|
||||
it('supports jsonp calls', function (done) {
|
||||
api
|
||||
.get(`${endPoint('createPad')}&jsonp=jsonp_1&padID=${testPadId}`)
|
||||
.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 a new issue