Added a test for appending the API key to a URL parameter

Signed-off-by: Karan Shah <karan.shah@simplybusiness.co.uk>
This commit is contained in:
Karan Shah
2022-02-04 14:24:03 +00:00
parent 63b037ba3a
commit d5470ec47f
@@ -58,7 +58,7 @@ describe('createRouter', () => {
});
describe('GET /api', () => {
it('appends the API Key properly', () => {
it('appends the API Key properly with no other url parameters', () => {
const options: RouterOptions = {
logger: getVoidLogger(),
airbrakeConfig,
@@ -71,5 +71,21 @@ describe('createRouter', () => {
'/random/endpoint?key=fakeApiKey',
);
});
it('appends the API Key properly despite there being other URL parameters', () => {
const options: RouterOptions = {
logger: getVoidLogger(),
airbrakeConfig,
};
const pathRewrite = generateAirbrakePathRewrite(options) as (
path: string,
) => string;
expect(
pathRewrite(
'/airbrake-backend/api/random/endpoint?param1=123&param2=abc',
),
).toBe('/random/endpoint?param1=123&param2=abc&key=fakeApiKey');
});
});
});