Skip to content

Commit

Permalink
Add tests for disabling docs in production
Browse files Browse the repository at this point in the history
  • Loading branch information
hagopj13 committed Dec 25, 2020
1 parent c9bc42b commit dd8bfd7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/routes/v1/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ defaultRoutes.forEach((route) => {
router.use(route.path, route.route);
});

if (config.env !== 'production') {
/* istanbul ignore next */
if (config.env === 'development') {
devRoutes.forEach((route) => {
router.use(route.path, route.route);
});
Expand Down
14 changes: 14 additions & 0 deletions tests/integration/docs.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const request = require('supertest');
const httpStatus = require('http-status');
const app = require('../../src/app');
const config = require('../../src/config/config');

describe('Auth routes', () => {
describe('GET /v1/docs', () => {
test('should return 404 when running in production', async () => {
config.env = 'production';
await request(app).get('/v1/docs').expect(httpStatus.NOT_FOUND);
config.env = process.env.NODE_ENV;
});
});
});

0 comments on commit dd8bfd7

Please sign in to comment.