Skip to content

Commit

Permalink
test: 💍 add extra unit test for root embeddable type
Browse files Browse the repository at this point in the history
  • Loading branch information
streamich committed Apr 30, 2020
1 parent 17ebb52 commit d72961b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ interface CompatibilityParams {
isEdit?: boolean;
isValueClickTriggerSupported?: boolean;
isEmbeddableEnhanced?: boolean;
rootType?: string;
}

describe('isCompatible', () => {
Expand All @@ -59,6 +60,7 @@ describe('isCompatible', () => {
isEdit = true,
isValueClickTriggerSupported = true,
isEmbeddableEnhanced = true,
rootType = 'dashboard',
}: CompatibilityParams,
expectedResult: boolean = true
): Promise<void> {
Expand All @@ -71,6 +73,8 @@ describe('isCompatible', () => {
}
);

embeddable.rootType = rootType;

if (isEmbeddableEnhanced) {
embeddable = enhanceEmbeddable(embeddable);
}
Expand Down Expand Up @@ -106,6 +110,12 @@ describe('isCompatible', () => {
isEdit: false,
});
});

test('not compatible if root embeddable is not "dashboard"', async () => {
await assertNonCompatibility({
rootType: 'visualization',
});
});
});

describe('execute', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { TriggerContextMapping } from '../../../../../../../src/plugins/ui_actio
import { uiActionsEnhancedPluginMock } from '../../../../../advanced_ui_actions/public/mocks';

export class MockEmbeddable extends Embeddable {
public rootType = 'dashboard';
public readonly type = 'mock';
private readonly triggers: Array<keyof TriggerContextMapping> = [];
constructor(
Expand All @@ -31,7 +32,7 @@ export class MockEmbeddable extends Embeddable {
}
public getRoot() {
return {
type: 'dashboard',
type: this.rootType,
} as Embeddable;
}
}
Expand Down

0 comments on commit d72961b

Please sign in to comment.