test: update cases for Mention

This commit is contained in:
zy410419243 2019-03-09 14:35:05 +08:00
parent 8eec4a801a
commit 64b6197441

View File

@ -1,6 +1,7 @@
import React from 'react';
import { mount } from 'enzyme';
import Mention from '..';
import { Nav } from 'rc-editor-mention';
const { toContentState } = Mention;
@ -113,4 +114,25 @@ describe('Mention', () => {
expect(items.length).toBe(1);
expect(items.at(0).props().children).toBe('bamboo');
});
it('onBlur', () => {
const e = { test: 1 };
const onBlur = event => {
expect(event).toEqual(e);
};
const wrapper = mount(<Mention onBlur={onBlur} />).instance();
wrapper.onBlur(e);
expect(wrapper.state.focus).toBe(false);
});
it('check filteredSuggestions', () => {
let wrapper = mount(<Mention defaultSuggestions={[<Nav value="light" />]} />).instance();
wrapper.defaultSearchChange('test');
expect(wrapper.state.filteredSuggestions).toEqual([]);
wrapper.defaultSearchChange('light');
expect(wrapper.state.filteredSuggestions).toEqual([<Nav value="light" />]);
wrapper = mount(<Mention defaultSuggestions={[<Nav />]} />).instance();
wrapper.defaultSearchChange('test');
expect(wrapper.state.filteredSuggestions).toEqual([<Nav />]);
});
});