Skip to content

Commit

Permalink
remove duplicated test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
RaoHai committed Dec 30, 2016
1 parent 159f725 commit 15451d6
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 69 deletions.
16 changes: 0 additions & 16 deletions tests/Select.combobox.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,20 +72,4 @@ describe('Select.combobox', () => {
dropdownWrapper.find('MenuItem').first().simulate('click');
expect(wrapper.state().inputValue).toBe('1');
});

it('combox could comstomize input element', () => {
const wrapper = mount(
<Select combobox getInputElement={() => <textarea />}>
<Option value="1">1</Option>
<Option value="2">2</Option>
</Select>
);

expect(wrapper.find('textarea').length).toBe(1);
wrapper.find('.rc-select').simulate('click');
const dropdownWrapper = mount(wrapper.find('Trigger').node.getComponent());

dropdownWrapper.find('MenuItem').first().simulate('click');
expect(wrapper.state().inputValue).toBe('1');
});
});
39 changes: 0 additions & 39 deletions tests/Select.multiple.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,43 +49,4 @@ describe('Select.multiple', () => {
expect(wrapper.state().open).toBe(false);
expect(input.node.focus).toBeCalled();
});

it('multiple could comstomize input element', () => {
const handleChange = jest.fn();
const wrapper = mount(
<Select
multiple
optionLabelProp="children"
tokenSeparators={[',']}
onChange={handleChange}
getInputElement={() => <textarea />}
>
<OptGroup key="group1">
<Option value="1">One</Option>
</OptGroup>
<OptGroup key="group2">
<Option value="2">Two</Option>
</OptGroup>
</Select>,
);
const input = wrapper.find('textarea');
input.node.focus = jest.fn();

input.simulate('change', { target: {
value: 'One',
} });

input.simulate('change', { target: {
value: 'One,Two,Three',
} });

expect(handleChange).toBeCalledWith(['1', '2']);
expect(wrapper.state().value).toEqual([
{ key: '1', label: 'One' },
{ key: '2', label: 'Two' },
]);
expect(wrapper.state().inputValue).toBe('');
expect(wrapper.state().open).toBe(false);
expect(input.node.focus).toBeCalled();
});
});
16 changes: 16 additions & 0 deletions tests/Select.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -408,4 +408,20 @@ describe('Select', () => {

expect(input.focus).toBeCalled();
});

it('combox could comstomize input element', () => {
const wrapper = mount(
<Select combobox getInputElement={() => <textarea />}>
<Option value="1">1</Option>
<Option value="2">2</Option>
</Select>
);

expect(wrapper.find('textarea').length).toBe(1);
wrapper.find('.rc-select').simulate('click');
const dropdownWrapper = mount(wrapper.find('Trigger').node.getComponent());

dropdownWrapper.find('MenuItem').first().simulate('click');
expect(wrapper.state().inputValue).toBe('1');
});
});
14 changes: 0 additions & 14 deletions tests/Select.tags.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,6 @@ describe('Select.tags', () => {
expect(wrapper.state().value).toEqual([{ key: 'foo', label: 'foo', title: undefined }]);
});

it('tags could comstomize input element', () => {
const wrapper = mount(
<Select tags getInputElement={() => <textarea />} />
);

expect(wrapper.find('textarea').length).toBe(1);

wrapper.find('textarea')
.simulate('change', { target: { value: 'foo' } })
.simulate('keyDown', { keyCode: KeyCode.ENTER });

expect(wrapper.state().value).toEqual([{ key: 'foo', label: 'foo', title: undefined }]);
});

it('tokenize input', () => {
const handleChange = jest.fn();
const wrapper = mount(
Expand Down

0 comments on commit 15451d6

Please sign in to comment.