Skip to content

Commit 1830059

Browse files
committed
feat(cli): add support for --yes option in command line arguments and test non-interactive mode
1 parent 6275dc1 commit 1830059

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

packages/aws-cdk/test/cli/cli.test.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,13 @@ jest.mock('../../lib/cli/parse-command-line-arguments', () => ({
5959
'stack-name': 'sampleStack',
6060
});
6161
}
62+
if (args.includes('--yes')) {
63+
return Promise.resolve({
64+
_: ['deploy'],
65+
yes: true,
66+
parameters: [{}],
67+
});
68+
}
6269
return Promise.resolve({ _: [] });
6370
}),
6471
}));
@@ -122,3 +129,20 @@ test('should convert language alias to full language name', async () => {
122129
}),
123130
);
124131
});
132+
133+
test('when --yes option is provided, CliIoHost is in non-interactive mode', async () => {
134+
const migrateSpy = jest.spyOn(cdkToolkitModule.CdkToolkit.prototype, 'deploy').mockResolvedValue();
135+
const execSpy = jest.spyOn(CliIoHost, 'instance');
136+
137+
await exec(['deploy', '--yes']);
138+
139+
expect(execSpy).toHaveBeenCalledWith(
140+
expect.objectContaining({
141+
nonInteractive: true,
142+
}),
143+
true,
144+
);
145+
146+
migrateSpy.mockRestore();
147+
execSpy.mockRestore();
148+
});

0 commit comments

Comments
 (0)