Skip to content

Commit

Permalink
Add test for cadidb.service without connection (mock) (#69)
Browse files Browse the repository at this point in the history
  • Loading branch information
williambelle authored Jul 13, 2023
1 parent 05dd535 commit 6081f8b
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tests/unit.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,15 @@ describe('Test API Unit ("/api/unit")', () => {
console.error = originalConsoleError;
});

test('It should return an error without Cadi DB connection', async () => {
// Do not mock anything in this test.
const response = await request(app).get('/api/unit?q=zzz');
expect(response.statusCode).toBe(400);
expect(response.text).toMatch('Oops, something went wrong');
expect(testOutput.length).toBe(1);
expect(testOutput[0]).toMatch('error');
});

test('It should return nothing', async () => {
const mockConnection = {
query: jest.fn().mockResolvedValue([[]]),
Expand Down

0 comments on commit 6081f8b

Please sign in to comment.