Mailspring/app/internal_packages/composer-emoji/specs/emoji-button-popover-spec.jsx

52 lines
1.8 KiB
React
Raw Normal View History

import React from 'react';
import ReactTestUtils from 'react-dom/test-utils';
import {findDOMNode} from 'react-dom';
import {renderIntoDocument} from '../../../spec/nylas-test-utils';
import Contenteditable from '../../../src/components/contenteditable/contenteditable';
import EmojiButtonPopover from '../lib/emoji-button-popover';
import EmojiComposerExtension from '../lib/emoji-composer-extension';
describe('EmojiButtonPopover', function emojiButtonPopover() {
2016-05-06 13:30:34 +08:00
beforeEach(() => {
this.position = {
x: 20,
y: 40,
}
spyOn(EmojiButtonPopover.prototype, 'calcPosition').andReturn(this.position);
spyOn(EmojiComposerExtension, '_onSelectEmoji').andCallThrough();
this.component = renderIntoDocument(<EmojiButtonPopover />);
this.canvas = findDOMNode(ReactTestUtils.findRenderedDOMComponentWithTag(this.component, 'canvas'));
this.composer = renderIntoDocument(
<Contenteditable
value={''}
onChange={jasmine.createSpy('onChange')}
2016-05-07 05:36:11 +08:00
extensions={[EmojiComposerExtension]}
/>
);
});
2016-05-06 13:30:34 +08:00
describe('when inserting emoji', () => {
it('should insert emoji on click', () => {
ReactTestUtils.Simulate.mouseDown(this.canvas);
expect(EmojiComposerExtension._onSelectEmoji).toHaveBeenCalled();
});
});
2016-05-06 13:30:34 +08:00
describe('when searching for emoji', () => {
it('should filter for matches', () => {
this.searchNode = findDOMNode(ReactTestUtils.findRenderedDOMComponentWithClass(this.component, 'search'))
const event = {
target: {
value: "heart",
},
}
ReactTestUtils.Simulate.change(this.searchNode, event);
ReactTestUtils.Simulate.mouseDown(this.canvas);
expect(EmojiComposerExtension._onSelectEmoji).toHaveBeenCalled();
});
});
});