mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-12-29 03:43:16 +08:00
27 lines
1 KiB
JavaScript
27 lines
1 KiB
JavaScript
import React from 'react';
|
|
import { scryRenderedDOMComponentsWithClass, Simulate } from 'react-dom/test-utils';
|
|
|
|
import MultiselectDropdown from '../../src/components/multiselect-dropdown';
|
|
import { renderIntoDocument } from '../mailspring-test-utils';
|
|
|
|
const makeDropdown = (items = [], props = {}) => {
|
|
return renderIntoDocument(<MultiselectDropdown {...props} items={items} />);
|
|
};
|
|
describe('MultiselectDropdown', function multiSelectedDropdown() {
|
|
describe('_onItemClick', () => {
|
|
it('calls onToggleItem function', () => {
|
|
const onToggleItem = jasmine.createSpy('onToggleItem');
|
|
const itemChecked = jasmine.createSpy('itemChecked');
|
|
const itemKey = i => i;
|
|
const dropdown = makeDropdown(['annie@nylas.com', 'anniecook@ostby.com'], {
|
|
onToggleItem,
|
|
itemChecked,
|
|
itemKey,
|
|
});
|
|
dropdown.setState({ selectingItems: true });
|
|
const item = scryRenderedDOMComponentsWithClass(dropdown, 'item')[0];
|
|
Simulate.mouseDown(item);
|
|
expect(onToggleItem).toHaveBeenCalled();
|
|
});
|
|
});
|
|
});
|