Skip to content

Commit 98717a2

Browse files
committed
fix sonarqube issues
1 parent c94e214 commit 98717a2

File tree

1 file changed

+22
-29
lines changed

1 file changed

+22
-29
lines changed

packages/event-handler/tests/unit/rest/helpers.ts

Lines changed: 22 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -76,36 +76,29 @@ export const createTestALBEvent = (
7676
path: string,
7777
httpMethod: string,
7878
headers: Record<string, string> = {},
79-
body: string | JSONValue = null
80-
): ALBEvent => {
81-
const stringBody =
82-
typeof body === 'string'
83-
? body
84-
: body !== null
85-
? JSON.stringify(body)
86-
: null;
87-
88-
return {
89-
path,
90-
httpMethod,
91-
headers,
92-
// ALB events represent GET and PATCH request bodies as empty strings
93-
body:
94-
httpMethod === HttpVerbs.GET || httpMethod === HttpVerbs.PATCH
95-
? ''
96-
: stringBody,
97-
multiValueHeaders: {},
98-
isBase64Encoded: false,
99-
queryStringParameters: undefined,
100-
multiValueQueryStringParameters: undefined,
101-
requestContext: {
102-
elb: {
103-
targetGroupArn:
104-
'arn:aws:elasticloadbalancing:us-east-1:123456789012:targetgroup/test/50dc6c495c0c9188',
105-
},
79+
body: JSONValue = null
80+
): ALBEvent => ({
81+
path,
82+
httpMethod,
83+
headers,
84+
// ALB events represent GET and PATCH request bodies as empty strings
85+
body:
86+
httpMethod === HttpVerbs.GET || httpMethod === HttpVerbs.PATCH
87+
? ''
88+
: body === null
89+
? null
90+
: JSON.stringify(body),
91+
multiValueHeaders: {},
92+
isBase64Encoded: false,
93+
queryStringParameters: undefined,
94+
multiValueQueryStringParameters: undefined,
95+
requestContext: {
96+
elb: {
97+
targetGroupArn:
98+
'arn:aws:elasticloadbalancing:us-east-1:123456789012:targetgroup/test/50dc6c495c0c9188',
10699
},
107-
};
108-
};
100+
},
101+
});
109102

110103
export const createTrackingMiddleware = (
111104
name: string,

0 commit comments

Comments
 (0)