* chore: add core module test cases * chore: fix tests * chore: add code coverage report * chore: split coverage step * chore: split coverage step * Update jan-electron-linter-and-test.yml * Update jan-electron-linter-and-test.yml * Update jan-electron-linter-and-test.yml * chore: update tests * chore: add web utils test cases * chore: add restful and helper tests * chore: add tests
22 lines
764 B
TypeScript
22 lines
764 B
TypeScript
|
|
import { commonRouter } from './common';
|
|
import { JanApiRouteConfiguration } from './helper/configuration';
|
|
|
|
test('commonRouter sets up routes for each key in JanApiRouteConfiguration', async () => {
|
|
const mockHttpServer = {
|
|
get: jest.fn(),
|
|
post: jest.fn(),
|
|
patch: jest.fn(),
|
|
put: jest.fn(),
|
|
delete: jest.fn(),
|
|
};
|
|
await commonRouter(mockHttpServer as any);
|
|
|
|
const expectedRoutes = Object.keys(JanApiRouteConfiguration);
|
|
expectedRoutes.forEach((key) => {
|
|
expect(mockHttpServer.get).toHaveBeenCalledWith(`/${key}`, expect.any(Function));
|
|
expect(mockHttpServer.get).toHaveBeenCalledWith(`/${key}/:id`, expect.any(Function));
|
|
expect(mockHttpServer.delete).toHaveBeenCalledWith(`/${key}/:id`, expect.any(Function));
|
|
});
|
|
});
|