@@ -2,6 +2,7 @@ import * as path from 'path';
2
2
import { Construct } from 'constructs' ;
3
3
import { readFileSync } from 'fs-extra' ;
4
4
import { toCloudFormation } from './util' ;
5
+ import * as cxapi from '../../cx-api' ;
5
6
import {
6
7
Stack , NestedStack , CfnStack , Resource , CfnResource , App , CfnOutput ,
7
8
} from '../lib' ;
@@ -168,6 +169,30 @@ describe('nested-stack', () => {
168
169
expect ( ( ) => toCloudFormation ( stack2 ) ) . toThrow (
169
170
/ C a n n o t u s e r e s o u r c e ' S t a c k 1 \/ M y N e s t e d S t a c k \/ M y R e s o u r c e ' i n a c r o s s - e n v i r o n m e n t f a s h i o n / ) ;
170
171
} ) ;
172
+
173
+ test ( 'requires bundling when root stack has exact match in BUNDLING_STACKS' , ( ) => {
174
+ const app = new App ( ) ;
175
+ const stack = new Stack ( app , 'Stack' ) ;
176
+ stack . node . setContext ( cxapi . BUNDLING_STACKS , [ 'Stack' ] ) ;
177
+
178
+ const child = new NestedStack ( stack , 'Child' ) ;
179
+ const child_2 = new NestedStack ( child , 'Child2' ) ;
180
+
181
+ expect ( child . bundlingRequired ) . toBe ( true ) ;
182
+ expect ( child_2 . bundlingRequired ) . toBe ( true ) ;
183
+ } ) ;
184
+
185
+ test ( 'not requires bundling when root stack has no match in BUNDLING_STACKS' , ( ) => {
186
+ const app = new App ( ) ;
187
+ const stack = new Stack ( app , 'Stack' ) ;
188
+ stack . node . setContext ( cxapi . BUNDLING_STACKS , [ 'Stack2' ] ) ;
189
+
190
+ const child = new NestedStack ( stack , 'Child' ) ;
191
+ const child_2 = new NestedStack ( child , 'Child2' ) ;
192
+
193
+ expect ( child . bundlingRequired ) . toBe ( false ) ;
194
+ expect ( child_2 . bundlingRequired ) . toBe ( false ) ;
195
+ } ) ;
171
196
} ) ;
172
197
173
198
class MyResource extends Resource {
0 commit comments