forked from floydspace/serverless-esbuild
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathminimal.test.ts
44 lines (32 loc) · 1.51 KB
/
minimal.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import fs from 'fs';
import path from 'path';
test('minimal', () => {
const testArtifactPath = path.resolve(__dirname, '../.test-artifacts/minimal/.serverless');
const cloudformation = require(path.join(testArtifactPath, 'cloudformation-template-update-stack.json'));
const indexContents = fs.readFileSync(path.join(testArtifactPath, 'index.js')).toString();
expect(indexContents).toMatchSnapshot();
expect(cloudformation.AWSTemplateFormatVersion).toMatchSnapshot();
expect(cloudformation.Description).toMatchSnapshot();
expect(cloudformation.Outputs).toMatchSnapshot({
ValidateIsinLambdaFunctionQualifiedArn: {
Value: { Ref: expect.any(String) },
},
});
expect(cloudformation.Outputs.ValidateIsinLambdaFunctionQualifiedArn.Value.Ref).toMatch(/^ValidateIsinLambdaVersion/);
const apiGatewayDeploymentPropertyKey = Object.keys(cloudformation.Resources).find((s) =>
s.startsWith('ApiGatewayDeployment')
) as keyof typeof cloudformation.Resources;
const { [apiGatewayDeploymentPropertyKey]: apiGatewayDeployment, ...deterministicResources } =
cloudformation.Resources;
expect(deterministicResources).toMatchSnapshot({
ValidateIsinLambdaFunction: {
Properties: {
Code: { S3Key: expect.stringContaining('minimal-example.zip') },
},
},
[Object.keys(deterministicResources).find((s) => s.startsWith('ValidateIsinLambdaVersion')) as string]: {
Properties: { CodeSha256: expect.any(String) },
},
});
expect(apiGatewayDeployment).toMatchSnapshot();
});