File tree Expand file tree Collapse file tree 2 files changed +34
-6
lines changed Expand file tree Collapse file tree 2 files changed +34
-6
lines changed Original file line number Diff line number Diff line change @@ -22,14 +22,16 @@ interface SynthConfig extends CommonSynthConfig {
22
22
type SynthOutputConfig = {
23
23
stacks : SynthesizedStack [ ] ;
24
24
} ;
25
- const SynthOutput = ( { stacks } : SynthOutputConfig ) : React . ReactElement => {
25
+ export const SynthOutput = ( {
26
+ stacks,
27
+ } : SynthOutputConfig ) : React . ReactElement => {
26
28
return (
27
29
< Text >
28
- { stacks ?. length ? (
29
- `Generated Terraform code for the stacks: ${ stacks . map ( ( s ) => s . name ) . join ( ", " ) } `
30
- ) : (
31
- "No stacks found in configuration."
32
- ) }
30
+ { stacks ?. length
31
+ ? `Generated Terraform code for the stacks: ${ stacks
32
+ . map ( ( s ) => s . name )
33
+ . join ( ", " ) } `
34
+ : "No stacks found in configuration." }
33
35
</ Text >
34
36
) ;
35
37
} ;
Original file line number Diff line number Diff line change
1
+ /**
2
+ * Copyright (c) HashiCorp, Inc.
3
+ * SPDX-License-Identifier: MPL-2.0
4
+ */
5
+
6
+ import React from "react" ;
7
+ import { render } from "ink-testing-library" ;
8
+ import { stripAnsi } from "../test-helper" ;
9
+ import { SynthOutput } from "../../bin/cmds/ui/synth" ;
10
+ import { SynthesizedStack } from "@cdktf/cli-core" ;
11
+
12
+ test ( "SynthOutput" , ( ) => {
13
+ const { lastFrame } = render ( < SynthOutput stacks = { [ ] } /> ) ;
14
+ expect ( stripAnsi ( lastFrame ( ) ) ) . toBe ( "No stacks found in configuration." ) ;
15
+ {
16
+ const multipleStacks = [
17
+ { name : "stack1" } ,
18
+ { name : "stack2" } ,
19
+ ] as SynthesizedStack [ ] ;
20
+
21
+ const { lastFrame } = render ( < SynthOutput stacks = { multipleStacks } /> ) ;
22
+ expect ( stripAnsi ( lastFrame ( ) ) ) . toBe (
23
+ "Generated Terraform code for the stacks: stack1, stack2" ,
24
+ ) ;
25
+ }
26
+ } ) ;
You can’t perform that action at this time.
0 commit comments