File tree 2 files changed +42
-6
lines changed
2 files changed +42
-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 (
14
+ < React . Fragment >
15
+ < SynthOutput stacks = { [ ] } />
16
+ </ React . Fragment >
17
+ ) ;
18
+ expect ( stripAnsi ( lastFrame ( ) ) ) . toBe ( "No stacks found in configuration." ) ;
19
+ {
20
+ const multipleStacks = [
21
+ { name : "stack1" } ,
22
+ { name : "stack2" } ,
23
+ ] as SynthesizedStack [ ] ;
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
+ ) ;
33
+ }
34
+ } ) ;
You can’t perform that action at this time.
0 commit comments