diff --git a/packages/kbn-server-route-repository-utils/src/format_request.test.ts b/packages/kbn-server-route-repository-utils/src/format_request.test.ts index e2ddcebebe68f..5c128cf57fefc 100644 --- a/packages/kbn-server-route-repository-utils/src/format_request.test.ts +++ b/packages/kbn-server-route-repository-utils/src/format_request.test.ts @@ -10,20 +10,21 @@ import { formatRequest } from './format_request'; describe('formatRequest', () => { + const version = 1; it('should return the correct path if the optional or required param is provided', () => { const pathParams = { param: 'testParam' }; - const resultOptionalEnd = formatRequest('GET /api/endpoint/{param?}', pathParams); + const resultOptionalEnd = formatRequest(`GET /api/endpoint/{param?} ${version}`, pathParams); expect(resultOptionalEnd.pathname).toBe('/api/endpoint/testParam'); - const resultRequiredEnd = formatRequest('GET /api/endpoint/{param}', pathParams); + const resultRequiredEnd = formatRequest(`GET /api/endpoint/{param} ${version}`, pathParams); expect(resultRequiredEnd.pathname).toBe('/api/endpoint/testParam'); }); it('should return the correct path if the only an optional param is provided', () => { - const resultOptEnd = formatRequest('GET /api/endpoint/{id?}', { id: 123 }); + const resultOptEnd = formatRequest(`GET /api/endpoint/{id?} ${version}`, { id: 123 }); expect(resultOptEnd.pathname).toBe('/api/endpoint/123'); }); it('should return the correct path if the optional param is not provided', () => { const pathParams = {}; - const resultEnd = formatRequest('GET /api/endpoint/{pathParamReq?}', pathParams); + const resultEnd = formatRequest(`GET /api/endpoint/{pathParamReq?} ${version}`, pathParams); expect(resultEnd.pathname).toBe('/api/endpoint'); }); });