Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
hbhong committed May 7, 2024
1 parent 36b65ec commit 91f15b5
Showing 1 changed file with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,37 @@ describe('EnumerationWidget', () => {
expect(onChange).toHaveBeenCalledWith(expect.anything(), { schema: {}, value: [] });
});

it('should pass the newest value to onFinish', async () => {
const onFinish = jest.fn();
render(
<EnumerationWidget
value={[{ values: ['yoo'] }]}
onChange={jest.fn()}
onFinish={onFinish}
onTrigger={jest.fn()}
schema={{}}
/>,
);

// when
await userEvent.click(screen.queryByRole('link', { name: 'Add item' }));
await userEvent.type(screen.queryByRole('textbox', { name: 'Enter new entry name' }), 'foo');
await userEvent.click(screen.queryByRole('link', { name: 'Validate' }));
// then
expect(onFinish).toHaveBeenCalledWith(expect.anything(), {
schema: {},
value: [
{
values: ['yoo'],
displayMode: 'DISPLAY_MODE_DEFAULT',
},
{
values: ['foo'],
},
],
});
});

describe('upload file', () => {
it('should add a upload icon and set data-feature', () => {
// when
Expand Down

0 comments on commit 91f15b5

Please sign in to comment.