Skip to content

Commit 4f69827

Browse files
committed
Updated tests and bumped to minor change
1 parent cea20ff commit 4f69827

File tree

2 files changed

+45
-34
lines changed

2 files changed

+45
-34
lines changed

.changeset/twenty-owls-march.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
'@as-integrations/aws-lambda': patch
2+
'@as-integrations/aws-lambda': minor
33
---
44

55
Added support for base64 encoding

src/__tests__/defineLambdaTestSuite.ts

Lines changed: 44 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -14,40 +14,51 @@ export function defineLambdaTestSuite<Event, Response>(
1414
shouldBase64Encode: boolean,
1515
) => (req: IncomingMessage, res: ServerResponse) => void,
1616
) {
17-
for (const shouldBase64Encode of [true, false]) {
18-
describe(`With base64 encoding ${
19-
shouldBase64Encode ? 'enabled' : 'disabled'
20-
}`, () => {
21-
defineIntegrationTestSuite(async function (
22-
serverOptions: ApolloServerOptions<BaseContext>,
23-
testOptions?: CreateServerForIntegrationTestsOptions,
24-
) {
25-
const httpServer = createServer();
26-
const server = new ApolloServer({
27-
...serverOptions,
28-
});
17+
describe.each([true, false])(
18+
'With base64 encoding set to %s',
19+
(shouldBase64Encode) => {
20+
defineIntegrationTestSuite(
21+
async function (
22+
serverOptions: ApolloServerOptions<BaseContext>,
23+
testOptions?: CreateServerForIntegrationTestsOptions,
24+
) {
25+
const httpServer = createServer();
26+
const server = new ApolloServer({
27+
...serverOptions,
28+
});
2929

30-
const handler = startServerAndCreateLambdaHandler(server, testOptions);
30+
const handler = startServerAndCreateLambdaHandler(
31+
server,
32+
testOptions,
33+
);
3134

32-
httpServer.addListener('request', mockServerFactory(handler as Handler<Event, Response>, shouldBase64Encode));
35+
httpServer.addListener(
36+
'request',
37+
mockServerFactory(
38+
handler as Handler<Event, Response>,
39+
shouldBase64Encode,
40+
),
41+
);
3342

34-
await new Promise<void>((resolve) => {
35-
httpServer.listen({ port: 0 }, resolve);
36-
});
37-
38-
return {
39-
server,
40-
url: urlForHttpServer(httpServer),
41-
async extraCleanup() {
42-
await new Promise<void>((resolve) => {
43-
httpServer.close(() => resolve());
44-
});
45-
},
46-
};
47-
}, {
48-
serverIsStartedInBackground: true,
49-
noIncrementalDelivery: true,
50-
});
51-
});
52-
}
43+
await new Promise<void>((resolve) => {
44+
httpServer.listen({ port: 0 }, resolve);
45+
});
46+
47+
return {
48+
server,
49+
url: urlForHttpServer(httpServer),
50+
async extraCleanup() {
51+
await new Promise<void>((resolve) => {
52+
httpServer.close(() => resolve());
53+
});
54+
},
55+
};
56+
},
57+
{
58+
serverIsStartedInBackground: true,
59+
noIncrementalDelivery: true,
60+
},
61+
);
62+
},
63+
);
5364
}

0 commit comments

Comments
 (0)