Skip to content

Commit e528e11

Browse files
authoredFeb 12, 2024
fix(msw): changed naming convention for response mock functions to avoid function name conflicts (#1217)
1 parent 12072f8 commit e528e11

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed
 

‎packages/mock/src/msw/index.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,11 @@ export const generateMSW = (
7777
const isReturnHttpResponse = value && value !== 'undefined';
7878

7979
const returnType = response.definition.success;
80-
const functionName = `get${pascal(operationId)}Mock`;
80+
const getResponseMockFunctionName = `get${pascal(operationId)}ResponseMock`;
8181
const handlerName = `get${pascal(operationId)}MockHandler`;
8282

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

8787
const handlerImplementation = `
@@ -91,8 +91,8 @@ export const ${handlerName} = (${isReturnHttpResponse && !isTextPlain ? `overrid
9191
return new HttpResponse(${
9292
isReturnHttpResponse
9393
? isTextPlain
94-
? `${functionName}()`
95-
: `JSON.stringify(overrideResponse ? overrideResponse : ${functionName}())`
94+
? `${getResponseMockFunctionName}()`
95+
: `JSON.stringify(overrideResponse ? overrideResponse : ${getResponseMockFunctionName}())`
9696
: null
9797
},
9898
{

0 commit comments

Comments
 (0)
Please sign in to comment.