From 754cdab896793c94b262c5967ac6da16d6cbbca1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Mon, 22 Nov 2021 23:38:04 -0500 Subject: [PATCH] test: debug routes in dev --- test/controllers.js | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/test/controllers.js b/test/controllers.js index e3d0dda050..077ef196b5 100644 --- a/test/controllers.js +++ b/test/controllers.js @@ -2406,6 +2406,46 @@ describe('Controllers', () => { }); }); + describe('test routes', () => { + if (process.env.NODE_ENV === 'development') { + it('should load debug route', (done) => { + request(`${nconf.get('url')}/debug/test`, {}, (err, res, body) => { + assert.ifError(err); + assert.equal(res.statusCode, 404); + assert(body); + done(); + }); + }); + + it('should load redoc read route', (done) => { + request(`${nconf.get('url')}/debug/spec/read`, {}, (err, res, body) => { + assert.ifError(err); + assert.equal(res.statusCode, 200); + assert(body); + done(); + }); + }); + + it('should load redoc write route', (done) => { + request(`${nconf.get('url')}/debug/spec/write`, {}, (err, res, body) => { + assert.ifError(err); + assert.equal(res.statusCode, 200); + assert(body); + done(); + }); + }); + + it('should load 404 for invalid type', (done) => { + request(`${nconf.get('url')}/debug/spec/doesnotexist`, {}, (err, res, body) => { + assert.ifError(err); + assert.equal(res.statusCode, 404); + assert(body); + done(); + }); + }); + } + }); + after((done) => { const analytics = require('../src/analytics'); analytics.writeData(done);