Skip to content

Commit

Permalink
Tests for the CliIoHost switching
Browse files Browse the repository at this point in the history
  • Loading branch information
rix0rrr committed Mar 4, 2025
1 parent a860335 commit d25fd89
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions packages/aws-cdk/test/toolkit/cli-io-host.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,38 @@ describe('CliIoHost', () => {
});
});

describe('notices stream selection', () => {
const NOTICES_MSG: IoMessage<unknown> = {
time: new Date(),
level: 'info',
action: 'notices',
code: 'CDK_TOOLKIT_I0100',
message: 'MESSAGE',
};

test('can send notices to stdout', async () => {
ioHost.noticesDestination = 'stdout';
await ioHost.notify(NOTICES_MSG);
// THEN
expect(mockStdout).toHaveBeenCalledWith(expect.stringContaining('MESSAGE'));
});

test('can send notices to stderr', async () => {
ioHost.noticesDestination = 'stderr';
await ioHost.notify(NOTICES_MSG);
// THEN
expect(mockStderr).toHaveBeenCalledWith(expect.stringContaining('MESSAGE'));
});

test('can drop notices', async () => {
ioHost.noticesDestination = 'drop';
await ioHost.notify(NOTICES_MSG);
// THEN
expect(mockStdout).not.toHaveBeenCalled();
expect(mockStderr).not.toHaveBeenCalled();
});
});

describe('message formatting', () => {
beforeEach(() => {
ioHost.isTTY = true;
Expand Down

0 comments on commit d25fd89

Please sign in to comment.