1
0
Fork 0

More tests

This commit is contained in:
Alan Plum 2016-02-04 11:12:41 +01:00
parent ab0db4e414
commit ca6bb83a84
No known key found for this signature in database
GPG Key ID: 8ED72A9A323B6EFD
1 changed files with 30 additions and 4 deletions

View File

@ -1,6 +1,7 @@
/*global describe, it, beforeEach */
'use strict';
require('chai').config.truncateThreshold = 0;
const joi = require('joi');
const expect = require('chai').expect;
const Service = require('@arangodb/foxx/service');
const createRouter = require('@arangodb/foxx/router');
@ -202,15 +203,40 @@ describe('Foxx Swagger', function () {
.that.has.a.property('description', 'Unexpected error.');
});
it('provides a default 200 response', function () {
it('does not provide any other default responses', function () {
service.router.get('/hello', noop());
service.buildRoutes();
expect(service.docs.paths).to.have.a.property('/hello')
.with.a.deep.property('get.responses.200')
.that.has.a.property('description', 'HTTP 200 OK.');
.with.a.deep.property('get.responses')
.that.has.all.keys('default');
});
it('TODO');
it('includes explicit responses', function () {
service.router.get('/hello', noop())
.response(200, 'Some response')
.response(400, 'Some error');
service.buildRoutes();
expect(service.docs.paths).to.have.a.property('/hello')
.with.a.deep.property('get.responses.200')
.that.has.a.property('description', 'Some response');
expect(service.docs.paths).to.have.a.property('/hello')
.with.a.deep.property('get.responses.400')
.that.has.a.property('description', 'Some error');
});
it('includes explicit schemas', function () {
service.router.get('/hello', noop())
.response(200, joi.object());
service.buildRoutes();
expect(service.docs.paths).to.have.a.property('/hello')
.with.a.deep.property('get.responses.200')
.that.has.a.property('schema')
.that.is.eql({
type: 'object',
properties: {},
additionalProperties: false
});
});
});
describe('"parameters"', function () {