Skip to content

Commit

Permalink
unit test adjusts
Browse files Browse the repository at this point in the history
  • Loading branch information
hassanad94 committed Oct 2, 2023
1 parent 5a3cbd9 commit 970eb1d
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ export const DatePicker: React.FC<ReactClientFieldSetting<DateTimeFieldSetting>>
label={settings.DisplayName}
id={settings.Name}
disabled={settings.ReadOnly}
// placeholder={settings.DisplayName}
InputLabelProps={{ shrink: true }}
required={settings.Compulsory}
format="yyyy MMMM dd"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,15 @@ exports[`Date/Date time field control in edit/new view should set all the props
utils={[Function]}
>
<PickerWithState
InputLabelProps={
Object {
"shrink": true,
}
}
allowKeyboardControl={true}
ampm={true}
disabled={true}
format="yyyy MMMM dd hh:mm aaaa"
fullWidth={true}
id="ModificationDate"
invalidDateMessage="Invalid Date Format"
label="Modification Date"
Expand All @@ -42,7 +46,6 @@ exports[`Date/Date time field control in edit/new view should set all the props
onChange={[Function]}
openTo="date"
orientation="portrait"
placeholder="Modification Date"
required={true}
showTabs={true}
value="1912-04-15T02:10:00.000Z"
Expand All @@ -67,10 +70,14 @@ exports[`Date/Date time field control in edit/new view should set all the props
utils={[Function]}
>
<PickerWithState
InputLabelProps={
Object {
"shrink": true,
}
}
allowKeyboardControl={true}
disabled={true}
format="yyyy MMMM dd"
fullWidth={true}
id="ModificationDate"
invalidDateMessage="Invalid Date Format"
label="Modification Date"
Expand All @@ -81,7 +88,6 @@ exports[`Date/Date time field control in edit/new view should set all the props
name="ModificationDate"
onChange={[Function]}
openTo="date"
placeholder="Modification Date"
required={true}
value="1912-04-15T02:10:00.000Z"
views={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@
exports[`Drop down list field control in edit/new view should set all the props 1`] = `
<WithStyles(ForwardRef(FormControl))
disabled={true}
fullWidth={true}
required={true}
style={
Object {
"minWidth": "220px",
}
}
>
<WithStyles(ForwardRef(InputLabel))
htmlFor="VersioningMode"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ exports[`Number field control in browse view should show the displayname and fie
exports[`Number field control in edit/new view should set all the props 1`] = `
<Fragment>
<WithStyles(ForwardRef(TextField))
InputLabelProps={
Object {
"shrink": true,
}
}
InputProps={
Object {
"endAdornment": <WithStyles(ForwardRef(InputAdornment))
Expand All @@ -35,7 +40,6 @@ exports[`Number field control in edit/new view should set all the props 1`] = `
}
}
disabled={true}
fullWidth={true}
id="Index"
inputProps={
Object {
Expand All @@ -47,7 +51,7 @@ exports[`Number field control in edit/new view should set all the props 1`] = `
label="Index"
name="Index"
onChange={[Function]}
placeholder="Index"
placeholder="0"
required={true}
type="number"
value={7}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ exports[`Short text field control in browse view should show the displayname and
exports[`Short text field control in edit/new view should set all the props 1`] = `
<Fragment>
<WithStyles(ForwardRef(TextField))
InputLabelProps={
Object {
"shrink": true,
}
}
autoComplete="off"
disabled={true}
fullWidth={true}
Expand All @@ -34,7 +39,6 @@ exports[`Short text field control in edit/new view should set all the props 1`]
label="Display name"
name="DisplayName"
onChange={[Function]}
placeholder="Display name"
required={true}
value="Hello World"
/>
Expand Down
2 changes: 0 additions & 2 deletions packages/sn-controls-react/test/date-picker.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion packages/sn-controls-react/test/number.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 7 additions & 3 deletions packages/sn-controls-react/test/reference-grid.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(<ReferenceGrid actionName="browse" settings={defaultSettings} />)
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(<ReferenceGrid actionName="browse" settings={defaultSettings} fieldValue={[] as any} />)
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 () => {
Expand All @@ -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 () => {
Expand Down
1 change: 0 additions & 1 deletion packages/sn-controls-react/test/short-text.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down

0 comments on commit 970eb1d

Please sign in to comment.