From e528e1192137c5fe567a9f1eaa70c4b477cb2711 Mon Sep 17 00:00:00 2001 From: Shodai Suzuki Date: Mon, 12 Feb 2024 22:47:55 +0900 Subject: [PATCH] fix(msw): changed naming convention for response mock functions to avoid function name conflicts (#1217) --- packages/mock/src/msw/index.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/mock/src/msw/index.ts b/packages/mock/src/msw/index.ts index 41d781ca8..47eb6afb4 100644 --- a/packages/mock/src/msw/index.ts +++ b/packages/mock/src/msw/index.ts @@ -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 = ` @@ -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 }, {