Skip to content

Commit

Permalink
Phani | Update Date format to DD/MM/YYYY
Browse files Browse the repository at this point in the history
  • Loading branch information
Phanindra-tw committed Dec 12, 2023
1 parent fdae660 commit 098549c
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const clickOnFirstDayOfNextMonth = (container) => {
const nextMonth = moment().add(1, 'month'); // Get the moment object for the next month
const firstDayNextMonth = nextMonth.startOf('month');
const datePickerInput = container.querySelector('.bx--date-picker__input');
fireEvent.change(datePickerInput, {target: {value: firstDayNextMonth.format("MM/DD/YYYY") }});
fireEvent.change(datePickerInput, {target: {value: firstDayNextMonth.format("DD/MM/YYYY") }});
fireEvent.blur(datePickerInput)
return firstDayNextMonth;
};
Expand Down Expand Up @@ -156,7 +156,7 @@ describe('Add Appointment', () => {
const selectedDate = clickOnFirstDayOfNextMonth(container)

const dateInputField = container.querySelector('.bx--date-picker__input');
expect(dateInputField.value).toBe(selectedDate.format('MM/DD/YYYY'));
expect(dateInputField.value).toBe(selectedDate.format('DD/MM/YYYY'));

fireEvent.click(getByText('Check and Save'));

Expand Down Expand Up @@ -230,8 +230,8 @@ describe('Add Appointment', () => {
"defaultNumberOfOccurrences": 10
}
};
const today = moment().format("MM/DD/YYYY");
const fiveDaysFromToday = moment().add(5, 'days').format("MM/DD/YYYY");
const today = moment().format("DD/MM/YYYY");
const fiveDaysFromToday = moment().add(5, 'days').format("DD/MM/YYYY");
const {getByText, container, queryAllByText, getByTestId, queryByText} = renderWithReactIntl(<AddAppointment
appConfig={config}/>);
const saveAppointmentSpy = jest.spyOn(addAppointmentService, 'saveRecurring');
Expand Down Expand Up @@ -425,8 +425,8 @@ describe('Add Appointment', () => {
appointmentParams={appointmentParams}/>);
expect(container.querySelectorAll('.bx--time-picker__input-field')[0].value).toBe(today.format('h:mm').toLowerCase());
expect(container.querySelectorAll('.bx--time-picker__input-field')[1].value).toBe(addTwoHoursFromNow.format('h:mm').toLowerCase());
const dateInputField = getByPlaceholderText('mm/dd/yyyy');
expect(dateInputField.value).toBe(today.format('MM/DD/YYYY'));
const dateInputField = getByPlaceholderText('dd/mm/yyyy');
expect(dateInputField.value).toBe(today.format('DD/MM/YYYY'));
});

it('should populate the start date, start time and end time coming as prop for recurring appointment', function () {
Expand All @@ -445,9 +445,9 @@ describe('Add Appointment', () => {
expect(container.querySelectorAll('.bx--time-picker__input-field')[0].value).toBe(today.format('h:mm').toLowerCase());
expect(container.querySelectorAll('.bx--time-picker__input-field')[1].value).toBe(addTwoHoursFromNow.format('h:mm').toLowerCase());

const dateInputField = getAllByPlaceholderText('mm/dd/yyyy')[0];
const dateInputField = getAllByPlaceholderText('dd/mm/yyyy')[0];

expect(dateInputField.value).toBe(today.format('MM/DD/YYYY'));
expect(dateInputField.value).toBe(today.format('DD/MM/YYYY'));
});

it('should not add second provider when maxAppointmentProvidersAllowed is 1', async () => {
Expand Down Expand Up @@ -549,8 +549,8 @@ describe('Add Appointment', () => {
const {container, getByPlaceholderText, queryByText} = renderWithReactIntl(<AddAppointment appConfig={config}/>);
const selectedDate = clickOnFirstDayOfNextMonth(container);

const dateInputField = getByPlaceholderText('mm/dd/yyyy');
expect(dateInputField.value).toBe(selectedDate.format('MM/DD/YYYY'));
const dateInputField = getByPlaceholderText('dd/mm/yyyy');
expect(dateInputField.value).toBe(selectedDate.format('DD/MM/YYYY'));

});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const DatePickerCarbon = props => {
const {onChange, value, title, minDate, testId, width, isDisabled, isRequired, showWarning, intl} = props;
let defaultTime = value;
if( value && value instanceof moment){
defaultTime = value.format("MM/DD/YYYY");
defaultTime = value.format("DD/MM/YYYY");
}
let titleText= title && <Title text={title} isRequired={isRequired}/>
const warningText = intl.formatMessage({
Expand All @@ -17,10 +17,10 @@ const DatePickerCarbon = props => {
});
return (
<div data-testid={testId || "datePicker"}>
<DatePicker datePickerType={"single"} onChange={onChange} disabled={isDisabled} minDate={minDate} value={defaultTime}>
<DatePicker datePickerType={"single"} onChange={onChange} disabled={isDisabled} minDate={minDate} value={defaultTime} dateFormat={"d/m/Y"}>
<DatePickerInput
id={"Appointment Date"}
placeholder={"mm/dd/yyyy"}
placeholder={"dd/mm/yyyy"}
labelText={titleText}
size={"md"}
style={{width: width || "250px"}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -580,9 +580,9 @@ const EditAppointment = props => {
return undefined;
}
if( moment(date).isBefore(moment().startOf("day"))){
return moment(date).format("MM-DD-YYYY");
return moment(date).format("DD-MM-YYYY");
}
return moment().format("MM-DD-YYYY")
return moment().format("DD-MM-YYYY")
}

const handleStatusChange = value => {
Expand Down Expand Up @@ -783,8 +783,8 @@ const EditAppointment = props => {
value={appointmentDetails.recurringEndDate}
isDisabled={componentsDisableStatus.endDate}
intl={intl}
minDate={(appointmentDetails.appointmentDate && moment(appointmentDetails.appointmentDate).format("MM-DD-YYYY"))
|| moment().format("MM-DD-YYYY")}
minDate={(appointmentDetails.appointmentDate && moment(appointmentDetails.appointmentDate).format("DD-MM-YYYY"))
|| moment().format("DD-MM-YYYY")}
testId={"recurring-end-date-selector"}/>
</div>)}
<div className={classNames(recurringContainerBlock)}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const clickOnFirstDayOfNextMonth = (container) => {
const nextMonth = moment().add(1, 'month'); // Get the moment object for the next month
const firstDayNextMonth = nextMonth.startOf('month');
const datePickerInput = container.querySelector('.bx--date-picker__input');
fireEvent.change(datePickerInput, {target: {value: firstDayNextMonth.format("MM/DD/YYYY") }});
fireEvent.change(datePickerInput, {target: {value: firstDayNextMonth.format("DD/MM/YYYY") }});
fireEvent.blur(datePickerInput)
return firstDayNextMonth;
};
Expand Down Expand Up @@ -446,7 +446,7 @@ describe('Edit Appointment', () => {
});
await flushPromises();
const dateSelectedField = containerInDom.querySelector('.bx--date-picker__input');
expect(moment(dateSelectedField.value).date()).toBe(11);
expect(moment(dateSelectedField.value,'DD/MM/YYYY').date()).toBe(11);
})
});

Expand Down

0 comments on commit 098549c

Please sign in to comment.