diff --git a/plugins/mobile_channel_header_plug/mobile_channel_header_plug.jsx b/plugins/mobile_channel_header_plug/mobile_channel_header_plug.jsx
index a12a9935f65c..7666144a6b5c 100644
--- a/plugins/mobile_channel_header_plug/mobile_channel_header_plug.jsx
+++ b/plugins/mobile_channel_header_plug/mobile_channel_header_plug.jsx
@@ -28,14 +28,14 @@ export default class MobileChannelHeaderPlug extends React.PureComponent {
createButton(plug) {
return (
-
this.fireAction(plug)}
>
{plug.icon}
-
+
);
}
diff --git a/tests/plugins/__snapshots__/mobile_channel_header_plug.test.jsx.snap b/tests/plugins/__snapshots__/mobile_channel_header_plug.test.jsx.snap
index f820538bb309..cd584a43c4ec 100644
--- a/tests/plugins/__snapshots__/mobile_channel_header_plug.test.jsx.snap
+++ b/tests/plugins/__snapshots__/mobile_channel_header_plug.test.jsx.snap
@@ -40,7 +40,7 @@ exports[`plugins/MobileChannelHeaderPlug should match snapshot with one extended
isDropdown={false}
theme={Object {}}
>
-
@@ -51,7 +51,7 @@ exports[`plugins/MobileChannelHeaderPlug should match snapshot with one extended
className="fa fa-anchor"
/>
-
+
`;
@@ -75,7 +75,7 @@ exports[`plugins/MobileChannelHeaderPlug should match snapshot with one extended
isDropdown={true}
theme={Object {}}
>
-
@@ -86,7 +86,7 @@ exports[`plugins/MobileChannelHeaderPlug should match snapshot with one extended
className="fa fa-anchor"
/>
-
+
`;
diff --git a/tests/plugins/mobile_channel_header_plug.test.jsx b/tests/plugins/mobile_channel_header_plug.test.jsx
index 6e5662eb3eed..26e30498697b 100644
--- a/tests/plugins/mobile_channel_header_plug.test.jsx
+++ b/tests/plugins/mobile_channel_header_plug.test.jsx
@@ -39,6 +39,14 @@ describe('plugins/MobileChannelHeaderPlug', () => {
/>
);
expect(wrapper).toMatchSnapshot();
+
+ wrapper.instance().fireAction = jest.fn();
+ expect(wrapper.find('button').exists()).toEqual(true);
+ expect(wrapper.find('li').exists()).toEqual(false);
+
+ wrapper.find('button').first().simulate('click');
+ expect(wrapper.instance().fireAction).toHaveBeenCalledTimes(1);
+ expect(wrapper.instance().fireAction).toBeCalledWith(testPlug);
});
test('should match snapshot with two extended components', () => {
@@ -78,6 +86,10 @@ describe('plugins/MobileChannelHeaderPlug', () => {
/>
);
expect(wrapper).toMatchSnapshot();
+
+ wrapper.instance().fireAction = jest.fn();
+ expect(wrapper.find('button').exists()).toEqual(true);
+ expect(wrapper.find('li').exists()).toEqual(false);
});
test('should match snapshot with two extended components, in dropdown', () => {
@@ -91,5 +103,39 @@ describe('plugins/MobileChannelHeaderPlug', () => {
/>
);
expect(wrapper).toMatchSnapshot();
+
+ wrapper.instance().fireAction = jest.fn();
+ expect(wrapper.find('button').exists()).toEqual(false);
+ expect(wrapper.find('li').exists()).toEqual(true);
+
+ wrapper.find('a').first().simulate('click');
+ expect(wrapper.instance().fireAction).toHaveBeenCalledTimes(1);
+ expect(wrapper.instance().fireAction).toBeCalledWith(testPlug);
+ });
+
+ test('should call plugin.action on fireAction', () => {
+ const channel = {id: 'channel_id'};
+ const channelMember = {id: 'channel_member_id'};
+ const newTestPlug = {
+ id: 'someid',
+ pluginId: 'pluginid',
+ icon: ,
+ action: jest.fn(),
+ dropdownText: 'some dropdown text',
+ };
+
+ const wrapper = mount(
+
+ );
+
+ wrapper.instance().fireAction(newTestPlug);
+ expect(newTestPlug.action).toHaveBeenCalledTimes(1);
+ expect(newTestPlug.action).toBeCalledWith(channel, channelMember);
});
});