Skip to content

Commit

Permalink
test: update cases for TagGroup
Browse files Browse the repository at this point in the history
  • Loading branch information
orzyyyy committed Apr 13, 2019
1 parent 844f708 commit f8fd598
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions src/tools/__tests__/TagGroup.test.tsx
Expand Up @@ -104,4 +104,54 @@ describe('TagGroup', () => {
wrapper.handleDrag();
expect(onChange).toBeCalled();
});

it('when typing in Input, onChange should be called', () => {
const onChange = jest.fn();
const wrapper = mount(
<TagGroup
onChange={onChange}
data={{
tag: {
editable: true,
input: 'test',
},
}}
/>,
);
wrapper.find('Input').simulate('change', { target: { value: '1' } });
expect(onChange).toHaveBeenCalled();
});

it('stopPropagation should work', () => {
const stopPropagation = jest.fn();
const wrapper: any = mount(
<TagGroup
data={{
tag: {
editable: true,
input: 'test',
},
}}
/>,
).instance();
wrapper.handleDragStart({ stopPropagation });
expect(stopPropagation).toHaveBeenCalled();
});

it('when blur, onChange should be called', () => {
const onChange = jest.fn();
const wrapper = mount(
<TagGroup
onChange={onChange}
data={{
tag: {
editable: true,
input: 'test',
},
}}
/>,
);
wrapper.find('Input').simulate('blur');
expect(onChange).toHaveBeenCalled();
});
});

0 comments on commit f8fd598

Please sign in to comment.