mattermost-mobile/app/components/message_attachments/action_menu/action_menu.test.tsx
Daniel Espino García f8e67c04ad
Migrate message attachments to typescript (#5127)
* Migrate attachment_image

* Migrate action_menu

* Migrate action_button

* migrate message_attachments

* Remove unintended commited file

* Fix tsc

* Fix tsc

* Fix lint

* Update references

* Make emoji functional component and fix imports

* Use ReactNode instead of JSXElement

* Convert action menu to FC

* Remove unneeded fragments

* Remove unneded undefined check

* Use undefined instead of nil in calculateDimensions

* Make sure height is always defined

* Use is valid URL

* Add missing types

* Lint fixes and remove lodash

* Revert package.json changes

* Put back fragments since they are actually needed

* Fix test

* Fix lint

* Address feedback
2021-04-22 18:21:44 -04:00

65 lines
1.7 KiB
TypeScript

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {shallow} from 'enzyme';
import React from 'react';
import ActionMenu from './action_menu';
describe('ActionMenu', () => {
const baseProps = {
postId: 'post1',
id: 'action1',
name: 'action',
options: [
{
text: 'One',
value: '1',
},
{
text: 'Two',
value: '2',
},
],
actions: {
selectAttachmentMenuAction: jest.fn(),
},
};
test('should start with nothing selected when no default is selected', () => {
const wrapper = shallow(<ActionMenu {...baseProps}/>);
expect(wrapper.props().selected).toBeUndefined();
});
test('should set selected based on default option', () => {
const props = {
...baseProps,
defaultOption: '2',
};
const wrapper = shallow(<ActionMenu {...props}/>);
expect(wrapper.props().selected).toBe(props.options[1]);
});
test('should start with previous value selected', () => {
const props = {
...baseProps,
defaultOption: '2',
selected: baseProps.options[0],
};
const wrapper = shallow(<ActionMenu {...props}/>);
expect(wrapper.props().selected).toBe(props.selected);
});
test('disabled works', () => {
const props = {
...baseProps,
disabled: true,
};
const wrapper = shallow(<ActionMenu {...props}/>);
expect(wrapper.props().disabled).toBe(true);
});
});