Skip to content

Commit

Permalink
add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
goemen committed May 15, 2024
1 parent ff5534b commit 63b3063
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 6 deletions.
4 changes: 0 additions & 4 deletions backend-external/src/v1/routes/pay-transparency-routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@ const validateApiKey =
* type: apiKey
* in: header
* name: x-api-key
* DeleteReportsApiKeyAuth:
* type: apiKey
* in: header
* name: x-api-delete-reports-key
* schemas:
* CalculatedData:
* type: object
Expand Down
4 changes: 2 additions & 2 deletions backend-external/src/v1/services/pay-transparency-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const payTransparencyService = {
};
const { status, data } = await utils
.backendAxios()
.get('/external-consumer-api/v1/', axiosConfig);
.get('/external-consumer-api/v1/reports', axiosConfig);
return { status, data };
},
async deleteReports(req: Request) {
Expand All @@ -33,7 +33,7 @@ export const payTransparencyService = {
const { status, data } = await utils.backendAxios().delete<{
error: boolean;
message: string;
}>('/external-consumer-api/v1/delete-reports', axiosConfig);
}>('/external-consumer-api/v1/reports', axiosConfig);
return { status, data };
},
};
26 changes: 26 additions & 0 deletions backend/src/v1/routes/external-consumer-routes.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,4 +144,30 @@ describe('external-consumer-routes', () => {
return request(app).get('').expect(200);
});
});

describe('/ DELETE', () => {
it('should delete reports', () => {
return request(app)
.delete('/')
.expect(200)
.expect(({ body }) => {
expect(body).toEqual({
error: false,
message: 'Reports deleted'
});
});
});
it('should fail delete reports and return error', () => {
mockDeleteReports.mockRejectedValue({message: 'Failed to delete reports'})
return request(app)
.delete('/')
.expect(200)
.expect(({ body }) => {
expect(body).toEqual({
error: true,
message: 'Failed to delete reports',
});
});
});
})
});

0 comments on commit 63b3063

Please sign in to comment.