Skip to content

Commit 8ce552f

Browse files
add: synth ui unit tests
1 parent 1d6779f commit 8ce552f

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

packages/cdktf-cli/src/bin/cmds/ui/synth.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ interface SynthConfig extends CommonSynthConfig {
2222
type SynthOutputConfig = {
2323
stacks: SynthesizedStack[];
2424
};
25-
export const SynthOutput = ({ stacks }: SynthOutputConfig): React.ReactElement => {
25+
export const SynthOutput = ({
26+
stacks,
27+
}: SynthOutputConfig): React.ReactElement => {
2628
return (
2729
<Text>
2830
{stacks?.length

packages/cdktf-cli/src/test/ui/synth.test.tsx

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,26 @@ import { stripAnsi } from "../test-helper";
99
import { SynthOutput } from "../../bin/cmds/ui/synth";
1010
import { SynthesizedStack } from "@cdktf/cli-core";
1111

12-
test("SynthOutput", () => {
13-
const { lastFrame } = render(<React.Fragment><SynthOutput stacks={[]} /></React.Fragment>);
12+
test("SynthOutput", () => {
13+
const { lastFrame } = render(
14+
<React.Fragment>
15+
<SynthOutput stacks={[]} />
16+
</React.Fragment>
17+
);
1418
expect(stripAnsi(lastFrame())).toBe("No stacks found in configuration.");
1519
{
1620
const multipleStacks = [
1721
{ name: "stack1" },
18-
{ name: "stack2" }
22+
{ name: "stack2" },
1923
] as SynthesizedStack[];
20-
21-
const { lastFrame } = render(<React.Fragment><SynthOutput stacks={multipleStacks} /></React.Fragment>);
22-
expect(stripAnsi(lastFrame())).toBe("Generated Terraform code for the stacks: stack1, stack2");
24+
25+
const { lastFrame } = render(
26+
<React.Fragment>
27+
<SynthOutput stacks={multipleStacks} />
28+
</React.Fragment>
29+
);
30+
expect(stripAnsi(lastFrame())).toBe(
31+
"Generated Terraform code for the stacks: stack1, stack2"
32+
);
2333
}
24-
})
34+
});

0 commit comments

Comments
 (0)