Skip to content

Commit

Permalink
Remove magic number in operation handlers test
Browse files Browse the repository at this point in the history
  • Loading branch information
mdwheele committed Jun 2, 2020
1 parent 8fc1d6c commit 414aca6
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions test/operation.handler.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,23 @@ import { OpenApiValidator } from '../src';
import * as resolvers from '../src/resolvers';

describe('operation handler', () => {
let defaultNumberOfRoutes = null;

it('should not install handlers when nothing provided', async () => {
const apiSpec = path.join(__dirname, 'resources/eov-operations.yaml');
const app = express();

const oam = new OpenApiValidator({
apiSpec
})
});

oam.installSync(app);

expect(oam)
.to.have.property('options')
.to.deep.include({ operationHandlers: false });

expect(app._router.stack.length).to.equal(6)
defaultNumberOfRoutes = app._router.stack.length
})

it('should use the default handler when string provided', async () => {
Expand All @@ -40,7 +42,7 @@ describe('operation handler', () => {
resolver: resolvers.defaultResolver
}});

expect(app._router.stack.length).to.be.greaterThan(6)
expect(app._router.stack.length).to.be.greaterThan(defaultNumberOfRoutes)
});

it('can use a custom operation resolver', async () => {
Expand All @@ -63,6 +65,6 @@ describe('operation handler', () => {
.to.have.property('options')
.to.deep.include({ operationHandlers: handler});

expect(app._router.stack.length).to.be.greaterThan(6)
expect(app._router.stack.length).to.be.greaterThan(defaultNumberOfRoutes)
});
});

0 comments on commit 414aca6

Please sign in to comment.