Skip to content
This repository has been archived by the owner on Mar 13, 2024. It is now read-only.

Commit

Permalink
[MM-12336 && MM-12299] Add cursor pointer to mobile view plugin butto…
Browse files Browse the repository at this point in the history
…n and add tests (#1811)

* add cursor pointer to mobile view plugin button and add tests

* add test on fireAction
  • Loading branch information
saturninoabril authored and hmhealey committed Oct 3, 2018
1 parent a825d5c commit 85b5838
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ export default class MobileChannelHeaderPlug extends React.PureComponent {

createButton(plug) {
return (
<div
<button
className='navbar-toggle navbar-right__icon pull-right'
onClick={() => this.fireAction(plug)}
>
<span className='icon navbar-plugin-button'>
{plug.icon}
</span>
</div>
</button>
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ exports[`plugins/MobileChannelHeaderPlug should match snapshot with one extended
isDropdown={false}
theme={Object {}}
>
<div
<button
className="navbar-toggle navbar-right__icon pull-right"
onClick={[Function]}
>
Expand All @@ -51,7 +51,7 @@ exports[`plugins/MobileChannelHeaderPlug should match snapshot with one extended
className="fa fa-anchor"
/>
</span>
</div>
</button>
</MobileChannelHeaderPlug>
`;

Expand All @@ -75,7 +75,7 @@ exports[`plugins/MobileChannelHeaderPlug should match snapshot with one extended
isDropdown={true}
theme={Object {}}
>
<div
<button
className="navbar-toggle navbar-right__icon pull-right"
onClick={[Function]}
>
Expand All @@ -86,7 +86,7 @@ exports[`plugins/MobileChannelHeaderPlug should match snapshot with one extended
className="fa fa-anchor"
/>
</span>
</div>
</button>
</MobileChannelHeaderPlug>
`;

Expand Down
46 changes: 46 additions & 0 deletions tests/plugins/mobile_channel_header_plug.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down Expand Up @@ -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', () => {
Expand All @@ -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: <i className='fa fa-anchor'/>,
action: jest.fn(),
dropdownText: 'some dropdown text',
};

const wrapper = mount(
<MobileChannelHeaderPlug
components={[newTestPlug]}
channel={channel}
channelMember={channelMember}
theme={{}}
isDropdown={true}
/>
);

wrapper.instance().fireAction(newTestPlug);
expect(newTestPlug.action).toHaveBeenCalledTimes(1);
expect(newTestPlug.action).toBeCalledWith(channel, channelMember);
});
});

0 comments on commit 85b5838

Please sign in to comment.