From 91f15b549009ca9c0cb72302e869223d1aee7bbb Mon Sep 17 00:00:00 2001 From: hbhong Date: Tue, 7 May 2024 16:08:35 +0800 Subject: [PATCH] add test --- .../Enumeration/EnumerationWidget.test.js | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/packages/forms/src/UIForm/fields/Enumeration/EnumerationWidget.test.js b/packages/forms/src/UIForm/fields/Enumeration/EnumerationWidget.test.js index c9b495ad28d..09565a4d095 100644 --- a/packages/forms/src/UIForm/fields/Enumeration/EnumerationWidget.test.js +++ b/packages/forms/src/UIForm/fields/Enumeration/EnumerationWidget.test.js @@ -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( + , + ); + + // 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