mattermost-mobile/app/screens/search/recent_item.test.js
Elias Nahum ada6be9b7a
Update dependencies (#5686)
* Update dependencies

* Fix unsigned builds
2021-09-22 13:54:12 -03:00

36 lines
1.1 KiB
JavaScript

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {shallow} from 'enzyme';
import React from 'react';
import Preferences from '@mm-redux/constants/preferences';
import RecentItem from './recent_item';
describe('Search RecentItem', () => {
const item = {
terms: 'test',
};
const baseProps = {
item,
removeSearchTerms: jest.fn(),
setRecentValue: jest.fn(),
theme: Preferences.THEMES.denim,
};
test('should match snapshot and respond to events', () => {
const wrapper = shallow(
<RecentItem {...baseProps}/>,
);
expect(wrapper).toMatchSnapshot();
wrapper.find('TouchableHighlight').first().props().onPress();
expect(baseProps.setRecentValue).toHaveBeenCalledTimes(1);
expect(baseProps.setRecentValue).toHaveBeenCalledWith(item);
wrapper.find('TouchableOpacity').first().props().onPress();
expect(baseProps.setRecentValue).toHaveBeenCalledTimes(1);
expect(baseProps.setRecentValue).toHaveBeenCalledWith(item);
});
});