import { name } from '../../../version.json';
import { mount } from 'enzyme';
import React from 'react';
import WithHelpTrigger from '../../../ui/WithHelpTrigger';
import EditorContext from '../../../ui/EditorContext';
import * as EventDispatcher from '../../../event-dispatcher';
import { analyticsEventKey } from '../../../plugins/analytics/consts';
describe(name, () => {
describe('WithHelpTrigger', () => {
it('should render child component as is', () => {
const dummy = () =>
test
;
const wrapper = mount(
,
);
expect(wrapper.html()).toEqual('test
');
wrapper.unmount();
});
it('should pass function openHelp as parameter to render method', () => {
const stub = jest.fn();
stub.mockImplementation(() => test
);
const wrapper = mount(
,
);
expect(stub).toHaveBeenCalled();
wrapper.unmount();
});
describe('open help', () => {
it('should trigger help clicked analytics event', () => {
let mockDispatch;
const mockCreateDispatch = jest
.spyOn(EventDispatcher, 'createDispatch')
.mockReturnValue((mockDispatch = jest.fn()));
mount(
{
openHelp();
return null;
}}
/>
,
);
expect(mockDispatch).toHaveBeenCalledWith(analyticsEventKey, {
payload: {
action: 'clicked',
actionSubject: 'button',
actionSubjectId: 'helpButton',
attributes: { inputMethod: 'toolbar' },
eventType: 'ui',
},
});
mockCreateDispatch.mockRestore();
});
});
});
});