Skip to content

Commit

Permalink
fix(msw): changed naming convention for response mock functions to av…
Browse files Browse the repository at this point in the history
…oid function name conflicts (#1217)
  • Loading branch information
soartec-lab authored Feb 12, 2024
1 parent 12072f8 commit e528e11
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/mock/src/msw/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,11 @@ export const generateMSW = (
const isReturnHttpResponse = value && value !== 'undefined';

const returnType = response.definition.success;
const functionName = `get${pascal(operationId)}Mock`;
const getResponseMockFunctionName = `get${pascal(operationId)}ResponseMock`;
const handlerName = `get${pascal(operationId)}MockHandler`;

const mockImplementation = isReturnHttpResponse
? `export const ${functionName} = (${isResponseOverridable ? `overrideResponse: any = {}` : ''}): ${returnType} => (${value})\n\n`
? `export const ${getResponseMockFunctionName} = (${isResponseOverridable ? `overrideResponse: any = {}` : ''}): ${returnType} => (${value})\n\n`
: '';

const handlerImplementation = `
Expand All @@ -91,8 +91,8 @@ export const ${handlerName} = (${isReturnHttpResponse && !isTextPlain ? `overrid
return new HttpResponse(${
isReturnHttpResponse
? isTextPlain
? `${functionName}()`
: `JSON.stringify(overrideResponse ? overrideResponse : ${functionName}())`
? `${getResponseMockFunctionName}()`
: `JSON.stringify(overrideResponse ? overrideResponse : ${getResponseMockFunctionName}())`
: null
},
{
Expand Down

0 comments on commit e528e11

Please sign in to comment.