Skip to content

Commit

Permalink
unit test cases for date adapter added
Browse files Browse the repository at this point in the history
  • Loading branch information
shaharyar-shamshi committed Feb 29, 2024
1 parent 8f31c76 commit be4d55a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,17 @@ describe('<AdapterMomentHijri />', () => {

expectFieldValueV7(v7Response.getSectionsContainer(), localizedTexts[localeKey].value);
});

it('should set month, year, and date correctly', () => {
const initialDate = adapter.date('2020-01-01T23:44:00.000Z')!;
const newDate = adapter.setMonthYearDate(initialDate, 2018, 4, 15);

const v7Response = renderWithProps({
enableAccessibleFieldDOMStructure: true,
value: newDate,
});
expectFieldValueV7(v7Response.getSectionsContainer(), '١٤٣٩/٠٨/٢٩ ٠٩:٣٥');
});
});
});

Expand All @@ -107,17 +118,6 @@ describe('<AdapterMomentHijri />', () => {
clock,
Component: DateTimeField,
});

it('should set month, year, and date correctly', () => {
const initialDate = adapter.date('2020-01-01T23:44:00.000Z')!;
const newDate = adapter.setMonthYearDate(initialDate, 2018, 4, 15);

const v7Response = renderWithProps({
enableAccessibleFieldDOMStructure: true,
value: newDate,
});
expectFieldValueV7(v7Response.getSectionsContainer(), '١٤٣٩/٠٨/٢٩ ٠٩:٣٥');
});
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ export class AdapterMomentHijri extends AdapterMoment implements MuiPickersAdapt
return super.getYearRange([start, end]);
};

public setMonthYearDate = (value: Moment, month: number, year: number, date: number) => {
public setMonthYearDate = (value: Moment, year: number, month: number, date: number) => {
return value.clone().iYear(year).iMonth(month).iDate(date);
};
}

0 comments on commit be4d55a

Please sign in to comment.