Skip to content

Commit

Permalink
Routes Toggles
Browse files Browse the repository at this point in the history
  • Loading branch information
williambelle committed Jul 21, 2023
1 parent 08d5470 commit 0fb0d74
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions tests/app.test.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,31 @@
const request = require('supertest');
const app = require('../src/app');

describe('Test root ("/")', () => {
test('It should response the GET method', async () => {
function testNonEnabledRoute (envName, route) {
test(`It should get a 404 for "${route} when non enabled"`, async () => {
process.env[envName] = 'False';
const app = require('../src/app');

const response = await request(app).get(route);
expect(response.statusCode).toBe(404);
expect(response.text).toMatch('Oops! That page can\'t be found.');
});
}

describe('Test 404 routes', () => {
beforeEach(() => {
jest.resetModules();
});

test('It should get a 404 for "/"', async () => {
const app = require('../src/app');

const response = await request(app).get('/');
expect(response.statusCode).toBe(404);
expect(response.text).toMatch('Oops! That page can\'t be found.');
});

testNonEnabledRoute('SEARCH_API_ENABLE_CSE', '/api/cse');
testNonEnabledRoute('SEARCH_API_ENABLE_LDAP', '/api/ldap');
testNonEnabledRoute('SEARCH_API_ENABLE_UNIT', '/api/unit');
testNonEnabledRoute('SEARCH_API_ENABLE_GRAPHSEARCH', '/api/graphsearch');
});

0 comments on commit 0fb0d74

Please sign in to comment.