-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
08d5470
commit 0fb0d74
Showing
1 changed file
with
24 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); | ||
}); |