From 06b7743912000c6dd98b6aa5e52d94f8d8a2b78c Mon Sep 17 00:00:00 2001 From: streamich Date: Fri, 26 Jun 2020 10:46:00 +0200 Subject: [PATCH] =?UTF-8?q?test:=20=F0=9F=92=8D=20make=20tests=20green=20a?= =?UTF-8?q?gain?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../explore_data/explore_data_chart_action.test.ts | 13 ++++++++++--- .../explore_data_context_menu_action.test.ts | 13 ++++++++++--- .../public/actions/explore_data/shared.ts | 2 +- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/x-pack/plugins/discover_enhanced/public/actions/explore_data/explore_data_chart_action.test.ts b/x-pack/plugins/discover_enhanced/public/actions/explore_data/explore_data_chart_action.test.ts index a273f0d50e45e8..a5a82112ac91d2 100644 --- a/x-pack/plugins/discover_enhanced/public/actions/explore_data/explore_data_chart_action.test.ts +++ b/x-pack/plugins/discover_enhanced/public/actions/explore_data/explore_data_chart_action.test.ts @@ -139,9 +139,16 @@ describe('"Explore underlying data" panel action', () => { expect(isCompatible).toBe(false); }); - test('returns false if embeddable is not Visualize embeddable', async () => { - const { action, embeddable, context } = setup(); - (embeddable as any).type = 'NOT_VISUALIZE_EMBEDDABLE'; + test('returns false if embeddable has more than one index pattern', async () => { + const { action, output, context } = setup(); + output.indexPatterns = [ + { + id: 'index-ptr-foo', + }, + { + id: 'index-ptr-bar', + }, + ]; const isCompatible = await action.isCompatible(context); diff --git a/x-pack/plugins/discover_enhanced/public/actions/explore_data/explore_data_context_menu_action.test.ts b/x-pack/plugins/discover_enhanced/public/actions/explore_data/explore_data_context_menu_action.test.ts index e742b693809731..c362e554e96c04 100644 --- a/x-pack/plugins/discover_enhanced/public/actions/explore_data/explore_data_context_menu_action.test.ts +++ b/x-pack/plugins/discover_enhanced/public/actions/explore_data/explore_data_context_menu_action.test.ts @@ -125,9 +125,16 @@ describe('"Explore underlying data" panel action', () => { expect(isCompatible).toBe(false); }); - test('returns false if embeddable is not Visualize embeddable', async () => { - const { action, embeddable, context } = setup(); - (embeddable as any).type = 'NOT_VISUALIZE_EMBEDDABLE'; + test('returns false if embeddable has more than one index pattern', async () => { + const { action, output, context } = setup(); + output.indexPatterns = [ + { + id: 'index-ptr-foo', + }, + { + id: 'index-ptr-bar', + }, + ]; const isCompatible = await action.isCompatible(context); diff --git a/x-pack/plugins/discover_enhanced/public/actions/explore_data/shared.ts b/x-pack/plugins/discover_enhanced/public/actions/explore_data/shared.ts index a1587a7b215034..c7051413e8f250 100644 --- a/x-pack/plugins/discover_enhanced/public/actions/explore_data/shared.ts +++ b/x-pack/plugins/discover_enhanced/public/actions/explore_data/shared.ts @@ -20,5 +20,5 @@ export const getIndexPatterns = (embeddable?: IEmbeddable): string[] => { return isOutputWithIndexPatterns(output) ? output.indexPatterns.map(({ id }) => id) : []; }; -export const hasExactlyOneIndexPattern = (embeddable?: IEmbeddable): string[] => +export const hasExactlyOneIndexPattern = (embeddable?: IEmbeddable): boolean => getIndexPatterns(embeddable).length === 1;