-
Notifications
You must be signed in to change notification settings - Fork 1
/
constructs-jsx.test.tsx
53 lines (43 loc) · 1.21 KB
/
constructs-jsx.test.tsx
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
45
46
47
48
49
50
51
52
53
import { expect as expectCDK, haveResource } from "@aws-cdk/assert";
import * as cdk from "@aws-cdk/core";
import * as sns from "@aws-cdk/aws-sns";
import { ConstructsJsxStack } from "../lib/constructs-jsx-stack";
import { createRef, render } from "../src/constructs-jsx";
test("SQS Queue Created", () => {
// Arrange
const stack = createRef<cdk.Stack>(null);
// Act
render(<ConstructsJsxStack ref={stack} />, new cdk.App());
// Assert
expectCDK(stack.current!).to(
haveResource("AWS::SQS::Queue", {
VisibilityTimeout: 300,
})
);
});
test("SNS Topic Created", () => {
// Arrange
const stack = createRef<cdk.Stack>(null);
// Act
render(<ConstructsJsxStack ref={stack} />, new cdk.App());
// Assert
expectCDK(stack.current!).to(haveResource("AWS::SNS::Topic"));
});
test("SNS Topic Created from children", () => {
// Arrange
const stack = createRef<cdk.Stack>(null);
function Test({ children, ref }: any) {
// @ts-ignore
return <cdk.Stack ref={ref}>{children}</cdk.Stack>;
}
// Act
render(
<Test ref={stack}>
{/* @ts-ignore */}
<sns.Topic />
</Test>,
new cdk.App()
);
// Assert
expectCDK(stack.current!).to(haveResource("AWS::SNS::Topic"));
});