From 970eb1d75165a68e3f07b492ec033fd67d7eed22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81d=C3=A1m=20Hassan?= Date: Mon, 2 Oct 2023 12:07:51 +0200 Subject: [PATCH] unit test adjusts --- .../src/fieldcontrols/date-picker.tsx | 1 - .../test/__snapshots__/date-picker.test.tsx.snap | 14 ++++++++++---- .../test/__snapshots__/dropdown-list.test.tsx.snap | 6 +++++- .../test/__snapshots__/number.test.tsx.snap | 8 ++++++-- .../test/__snapshots__/short-text.test.tsx.snap | 6 +++++- .../sn-controls-react/test/date-picker.test.tsx | 2 -- packages/sn-controls-react/test/number.test.tsx | 2 +- .../sn-controls-react/test/reference-grid.test.tsx | 10 +++++++--- .../sn-controls-react/test/short-text.test.tsx | 1 - 9 files changed, 34 insertions(+), 16 deletions(-) diff --git a/packages/sn-controls-react/src/fieldcontrols/date-picker.tsx b/packages/sn-controls-react/src/fieldcontrols/date-picker.tsx index 790a24593..26dee7038 100644 --- a/packages/sn-controls-react/src/fieldcontrols/date-picker.tsx +++ b/packages/sn-controls-react/src/fieldcontrols/date-picker.tsx @@ -95,7 +95,6 @@ export const DatePicker: React.FC> label={settings.DisplayName} id={settings.Name} disabled={settings.ReadOnly} - // placeholder={settings.DisplayName} InputLabelProps={{ shrink: true }} required={settings.Compulsory} format="yyyy MMMM dd" diff --git a/packages/sn-controls-react/test/__snapshots__/date-picker.test.tsx.snap b/packages/sn-controls-react/test/__snapshots__/date-picker.test.tsx.snap index e025e8724..52bb97b91 100644 --- a/packages/sn-controls-react/test/__snapshots__/date-picker.test.tsx.snap +++ b/packages/sn-controls-react/test/__snapshots__/date-picker.test.tsx.snap @@ -26,11 +26,15 @@ exports[`Date/Date time field control in edit/new view should set all the props utils={[Function]} > diff --git a/packages/sn-controls-react/test/date-picker.test.tsx b/packages/sn-controls-react/test/date-picker.test.tsx index 49dad0f6c..babb5b074 100644 --- a/packages/sn-controls-react/test/date-picker.test.tsx +++ b/packages/sn-controls-react/test/date-picker.test.tsx @@ -71,7 +71,6 @@ describe('Date/Date time field control', () => { expect(wrapper.find(DateTimePicker).prop('name')).toBe(defaultSettings.Name) expect(wrapper.find(DateTimePicker).prop('id')).toBe(defaultSettings.Name) expect(wrapper.find(DateTimePicker).prop('label')).toBe(defaultSettings.DisplayName) - expect(wrapper.find(DateTimePicker).prop('placeholder')).toBe(defaultSettings.DisplayName) expect(wrapper.find(DateTimePicker).prop('required')).toBeTruthy() expect(wrapper.find(DateTimePicker).prop('disabled')).toBeTruthy() expect(wrapper).toMatchSnapshot() @@ -109,7 +108,6 @@ describe('Date/Date time field control', () => { expect(wrapper.find(MUIDatePicker).prop('name')).toBe(defaultSettings.Name) expect(wrapper.find(MUIDatePicker).prop('id')).toBe(defaultSettings.Name) expect(wrapper.find(MUIDatePicker).prop('label')).toBe(defaultSettings.DisplayName) - expect(wrapper.find(MUIDatePicker).prop('placeholder')).toBe(defaultSettings.DisplayName) expect(wrapper.find(MUIDatePicker).prop('required')).toBeTruthy() expect(wrapper.find(MUIDatePicker).prop('disabled')).toBeTruthy() expect(wrapper).toMatchSnapshot() diff --git a/packages/sn-controls-react/test/number.test.tsx b/packages/sn-controls-react/test/number.test.tsx index dacd8a111..7f8d35ccf 100644 --- a/packages/sn-controls-react/test/number.test.tsx +++ b/packages/sn-controls-react/test/number.test.tsx @@ -75,7 +75,7 @@ describe('Number field control', () => { expect(wrapper.find(TextField).prop('name')).toBe(defaultSettings.Name) expect(wrapper.find(TextField).prop('id')).toBe(defaultSettings.Name) expect(wrapper.find(TextField).prop('label')).toBe(defaultSettings.DisplayName) - expect(wrapper.find(TextField).prop('placeholder')).toBe(defaultSettings.DisplayName) + expect(wrapper.find(TextField).prop('placeholder')).toBe('0') expect(wrapper.find(TextField).prop('required')).toBeTruthy() expect(wrapper.find(TextField).prop('disabled')).toBeTruthy() expect(wrapper.find(FormHelperText).text()).toBe(defaultSettings.Description) diff --git a/packages/sn-controls-react/test/reference-grid.test.tsx b/packages/sn-controls-react/test/reference-grid.test.tsx index 2b5f12725..e7068ed77 100644 --- a/packages/sn-controls-react/test/reference-grid.test.tsx +++ b/packages/sn-controls-react/test/reference-grid.test.tsx @@ -83,12 +83,16 @@ describe('Reference grid field control', () => { describe('in browse view', () => { it('should show no value message when field value is not provided', () => { const wrapper = shallow() - expect(wrapper.find(Typography).text()).toBe(defaultLocalization.referenceGrid.noValue) + expect(wrapper.find(Typography).filter({ variant: 'body1' }).text()).toBe( + defaultLocalization.referenceGrid.noValue, + ) }) it('should show no value message when field value is empty array', () => { const wrapper = shallow() - expect(wrapper.find(Typography).text()).toBe(defaultLocalization.referenceGrid.noValue) + expect(wrapper.find(Typography).filter({ variant: 'body1' }).text()).toBe( + defaultLocalization.referenceGrid.noValue, + ) }) it('should render the default item template when there is a field value', async () => { @@ -102,7 +106,7 @@ describe('Reference grid field control', () => { }) expect(wrapper.find(DefaultItemTemplate)).toHaveLength(1) - expect(wrapper.find(InputLabel).text()).toBe(defaultSettings.DisplayName) + expect(wrapper.find(Typography).filter({ variant: 'caption' }).text()).toBe(defaultSettings.DisplayName) }) it('should create an allowed type list filter', async () => { diff --git a/packages/sn-controls-react/test/short-text.test.tsx b/packages/sn-controls-react/test/short-text.test.tsx index 32a7f8138..cbed3068a 100644 --- a/packages/sn-controls-react/test/short-text.test.tsx +++ b/packages/sn-controls-react/test/short-text.test.tsx @@ -53,7 +53,6 @@ describe('Short text field control', () => { expect(wrapper.find(TextField).prop('name')).toBe(defaultSettings.Name) expect(wrapper.find(TextField).prop('id')).toBe(defaultSettings.Name) expect(wrapper.find(TextField).prop('label')).toBe(defaultSettings.DisplayName) - expect(wrapper.find(TextField).prop('placeholder')).toBe(defaultSettings.DisplayName) expect(wrapper.find(TextField).prop('required')).toBeTruthy() expect(wrapper.find(TextField).prop('disabled')).toBeTruthy() expect(wrapper.find(FormHelperText).text()).toEqual('description')