From ad572e8952dd67e1cc9429de666dad40d2ef4772 Mon Sep 17 00:00:00 2001 From: Rico Huijbers Date: Tue, 5 Apr 2022 14:38:00 +0200 Subject: [PATCH] Fix tests --- packages/aws-cdk/test/cdk-toolkit.test.ts | 4 +++- packages/aws-cdk/test/import.test.ts | 16 ++++++++-------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/packages/aws-cdk/test/cdk-toolkit.test.ts b/packages/aws-cdk/test/cdk-toolkit.test.ts index 52922d51ed50f..fd77172a9dff7 100644 --- a/packages/aws-cdk/test/cdk-toolkit.test.ts +++ b/packages/aws-cdk/test/cdk-toolkit.test.ts @@ -681,7 +681,9 @@ describe('synth', () => { const toolkit = defaultToolkitSetup(); await toolkit.synth([], false, false); - expect(stderrMock.mock.calls[1][0]).toMatch('Test-Stack-A-Display-Name, Test-Stack-B'); + // Separate tests as colorizing hampers detection + expect(stderrMock.mock.calls[1][0]).toMatch('Test-Stack-A-Display-Name'); + expect(stderrMock.mock.calls[1][0]).toMatch('Test-Stack-B'); }); test('with no stdout option', async () => { diff --git a/packages/aws-cdk/test/import.test.ts b/packages/aws-cdk/test/import.test.ts index 42dc72a4042cd..816b89abd535d 100644 --- a/packages/aws-cdk/test/import.test.ts +++ b/packages/aws-cdk/test/import.test.ts @@ -58,8 +58,8 @@ test('discovers importable resources', async () => { }); const importer = new ResourceImporter(STACK_WITH_QUEUE, deployments); - const resources = await importer.discoverImportableResources(); - expect(resources).toEqual([ + const { additions } = await importer.discoverImportableResources(); + expect(additions).toEqual([ expect.objectContaining({ logicalId: 'MyQueue', }), @@ -86,11 +86,11 @@ test('asks human for resource identifiers', async () => { // GIVEN givenCurrentStack(STACK_WITH_QUEUE.stackName, { Resources: {} }); const importer = new ResourceImporter(STACK_WITH_QUEUE, deployments); - const resources = await importer.discoverImportableResources(); + const { additions } = await importer.discoverImportableResources(); // WHEN promptlyPrompt.mockResolvedValue('TheQueueName'); - const importable = await importer.askForResourceIdentifiers(resources); + const importable = await importer.askForResourceIdentifiers(additions); // THEN expect(importable.resourceMap).toEqual({ @@ -109,11 +109,11 @@ test('asks human to confirm automic import if identifier is in template', async // GIVEN givenCurrentStack(STACK_WITH_NAMED_QUEUE.stackName, { Resources: {} }); const importer = new ResourceImporter(STACK_WITH_NAMED_QUEUE, deployments); - const resources = await importer.discoverImportableResources(); + const { additions } = await importer.discoverImportableResources(); // WHEN promptlyConfirm.mockResolvedValue(true); - const importable = await importer.askForResourceIdentifiers(resources); + const importable = await importer.askForResourceIdentifiers(additions); // THEN expect(importable.resourceMap).toEqual({ @@ -132,9 +132,9 @@ test('asks human to confirm automic import if identifier is in template', async // GIVEN givenCurrentStack(STACK_WITH_QUEUE.stackName, { Resources: {} }); const importer = new ResourceImporter(STACK_WITH_QUEUE, deployments); - const resources = await importer.discoverImportableResources(); + const { additions } = await importer.discoverImportableResources(); const importMap: ImportMap = { - importResources: resources, + importResources: additions, resourceMap: { MyQueue: { QueueName: 'TheQueueName' }, },