Skip to content

Commit

Permalink
test: 💍 add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
streamich committed Oct 26, 2020
1 parent 9564732 commit 9fedbcf
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ describe('isCompatible', () => {
});
});

test('not compatible if no triggers intersection', async () => {
test('not compatible if no triggers intersect', async () => {
await assertNonCompatibility({
actionFactoriesTriggers: [],
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,25 +87,25 @@ describe('VALUE_CLICK_TRIGGER', () => {
]) as ValueClickTriggerEventScope;
expect(mockEventScope.points.length).toBeGreaterThan(3);
expect(mockEventScope.points).toMatchInlineSnapshot(`
Array [
Object {
"key": "event.points.0.key",
"value": "event.points.0.value",
},
Object {
"key": "event.points.1.key",
"value": "event.points.1.value",
},
Object {
"key": "event.points.2.key",
"value": "event.points.2.value",
},
Object {
"key": "event.points.3.key",
"value": "event.points.3.value",
},
]
`);
Array [
Object {
"key": "event.points.0.key",
"value": "event.points.0.value",
},
Object {
"key": "event.points.1.key",
"value": "event.points.1.value",
},
Object {
"key": "event.points.2.key",
"value": "event.points.2.value",
},
Object {
"key": "event.points.3.key",
"value": "event.points.3.value",
},
]
`);
});
});

Expand All @@ -130,3 +130,12 @@ describe('VALUE_CLICK_TRIGGER', () => {
});
});
});

describe('CONTEXT_MENU_TRIGGER', () => {
test('getMockEventScope() results in empty scope', () => {
const mockEventScope = getMockEventScope([
'CONTEXT_MENU_TRIGGER',
]) as ValueClickTriggerEventScope;
expect(mockEventScope).toEqual({});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { UiActionsServiceEnhancements } from '../services';
import { ActionFactoryDefinition } from './action_factory_definition';
import { SerializedAction, SerializedEvent } from './types';
import { licensingMock } from '../../../licensing/public/mocks';
import { dynamicActionGrouping } from './dynamic_action_grouping';

const actionFactoryDefinition1: ActionFactoryDefinition = {
id: 'ACTION_FACTORY_1',
Expand Down Expand Up @@ -294,6 +295,27 @@ describe('DynamicActionManager', () => {
expect(manager.state.get().events.length).toBe(1);
});

test('adds revived actiosn to "dynamic action" grouping', async () => {
const { manager, uiActions, actions } = setup([]);
const action: SerializedAction = {
factoryId: actionFactoryDefinition1.id,
name: 'foo',
config: {},
};

uiActions.registerActionFactory(actionFactoryDefinition1);

await manager.start();

expect(manager.state.get().events.length).toBe(0);

await manager.createEvent(action, ['VALUE_CLICK_TRIGGER']);

const createdAction = actions.values().next().value;

expect(createdAction.grouping).toBe(dynamicActionGrouping);
});

test('optimistically adds event to UI state', async () => {
const { manager, uiActions } = setup([]);
const action: SerializedAction = {
Expand Down

0 comments on commit 9fedbcf

Please sign in to comment.