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:
@@ -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¶m2=abc',
|
||||
),
|
||||
).toBe('/random/endpoint?param1=123¶m2=abc&key=fakeApiKey');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user