Skip to content

Commit

Permalink
test(tags-field): add missing test to 100% coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
NicolasAuger committed Apr 8, 2019
1 parent fd4d34c commit ce71a4e
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions tests/TagsField.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -308,4 +308,29 @@ describe('<TagsField />', () => {
expect(component.find('.junipero-dropdown-menu').length).toBe(0);
});

it('should add a new tag when selecting an option in autocomplete ' +
'dropdown', () => {
jest.useFakeTimers();
const component = mount(
<TagsField
value={[]}
autoComplete={autoComplete}
autoCompleteUniqueValues={true}
/>
);
component.find('input').simulate('focus');
expect(component.state('focused')).toBe(true);
component.find('input').simulate('change', { target: { value: 'M' } });
jest.runAllTimers();
component.update();
expect(component.find('.junipero-dropdown-menu').length).toBe(1);
expect(component.find('.junipero-dropdown-item').length).toBe(1);
expect(component.find('.junipero-dropdown-item')
.find('.junipero-option').text()).toBe('Freeman');
component.find('.junipero-dropdown-item').find('.junipero-option')
.simulate('click');
expect(component.state('value').length).toBe(1);
expect(component.state('value').pop()).toBe('Freeman');
});

});

0 comments on commit ce71a4e

Please sign in to comment.