@@ -2,6 +2,7 @@ import * as path from 'path';
22import { Construct } from 'constructs' ;
33import { readFileSync } from 'fs-extra' ;
44import { toCloudFormation } from './util' ;
5+ import * as cxapi from '../../cx-api' ;
56import {
67 Stack , NestedStack , CfnStack , Resource , CfnResource , App , CfnOutput ,
78} from '../lib' ;
@@ -168,6 +169,30 @@ describe('nested-stack', () => {
168169 expect ( ( ) => toCloudFormation ( stack2 ) ) . toThrow (
169170 / 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 / ) ;
170171 } ) ;
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+ } ) ;
171196} ) ;
172197
173198class MyResource extends Resource {
0 commit comments