Skip to content

Commit

Permalink
WIP: add unit test
Browse files Browse the repository at this point in the history
Signed-off-by: Sumu <[email protected]>
  • Loading branch information
sumupitchayan committed Dec 23, 2024
1 parent 189bae3 commit 5149588
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions packages/aws-cdk-lib/core/test/aspect.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -309,4 +309,27 @@ describe('aspect', () => {
}
}
}

test.each([
{ stabilization: true },
{ stabilization: false },
])('Error is not thrown if Aspects.applied does not exist (stabilization: $stabilization)', ({ stabilization }) => {
const app = new App({ context: { '@aws-cdk/core:aspectStabilization': stabilization } });
const root = new Stack(app, 'My-Stack');
const child = new Bucket(root, 'my-bucket', {
bucketName: 'my-bucket',
});

Aspects.of(root).add(new Tag('AspectA', 'Visited'), { priority: 10 });

// "Monkey patching" - Override `applied` to simulate its absence
Object.defineProperty(Aspects.prototype, 'applied', {
value: undefined,
configurable: true,
});

expect(() => {
app.synth();
}).not.toThrow();
});
});

0 comments on commit 5149588

Please sign in to comment.