|
1 | | -import {Match, Template} from "aws-cdk-lib/assertions"; |
2 | 1 | import * as cdk from "aws-cdk-lib"; |
3 | | -import {DemoCloudfrontFunctionsStack} from "../lib/demo-cloudfront-functions-stack"; |
4 | 2 |
|
5 | 3 |
|
6 | 4 | test('Synthesizes the stack properly ', () => { |
7 | 5 | const app = new cdk.App(); |
8 | | - const functionsStack = new DemoCloudfrontFunctionsStack(app, 'functions-stack'); |
9 | | - const template = Template.fromStack(functionsStack); |
10 | | - |
11 | | - template.resourceCountIs('AWS::S3::Bucket', 1) |
12 | | - template.resourceCountIs('AWS::CloudFront::Function', 2); |
13 | | - |
14 | | - template.resourcePropertiesCountIs('AWS::CloudFront::Function', Match.objectLike({ |
15 | | - "Name": "RequestFunction", |
16 | | - }), 1); |
17 | | - |
18 | | - template.resourcePropertiesCountIs('AWS::CloudFront::Function', Match.objectLike({ |
19 | | - "Name": "ResponseFunction", |
20 | | - }), 1); |
21 | | - |
22 | | - template.resourcePropertiesCountIs('AWS::CloudFront::Distribution', { |
23 | | - "DistributionConfig": Match.objectLike({ |
24 | | - "DefaultCacheBehavior": Match.objectLike({ |
25 | | - "FunctionAssociations": [ |
26 | | - { |
27 | | - "EventType": "viewer-request", |
28 | | - "FunctionARN": Match.anyValue() |
29 | | - }, |
30 | | - { |
31 | | - "EventType": "viewer-response", |
32 | | - "FunctionARN": Match.anyValue() |
33 | | - } |
34 | | - ] |
35 | | - }) |
36 | | - }) |
37 | | - }, 1); |
38 | 6 | }); |
0 commit comments