Improved TagsSelector component test, covering different logic while adding tags

This commit is contained in:
Alejandro Celaya 2021-08-15 09:49:01 +02:00
parent b8a7dccf92
commit 4417a17d5c

View file

@ -49,10 +49,14 @@ describe('<TagsSelector />', () => {
]);
});
it('invokes onChange when new tags are added', () => {
wrapper.simulate('addition', { name: 'The-New-Tag' });
it.each([
[ 'The-New-Tag', [ ...tags, 'the-new-tag' ]],
[ 'comma,separated,tags', [ ...tags, 'comma', 'separated', 'tags' ]],
[ 'foo', tags ],
])('invokes onChange when new tags are added', (newTag, expectedTags) => {
wrapper.simulate('addition', { name: newTag });
expect(onChange).toHaveBeenCalledWith([ ...tags, 'the-new-tag' ]);
expect(onChange).toHaveBeenCalledWith(expectedTags);
});
it.each([