Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -418,19 +418,6 @@ describe('DetailsFieldsComponent', () => {
expect(component.saveEntry.emit).toHaveBeenCalledWith(data);
});

it('should not modify the start_date when start_hour has not been modified', () => {
const currentDate = moment().format('YYYY-MM-DD');
const startHour = moment().subtract(3, 'hours').format('HH:mm:ss');
const expectedStartDate = new Date(`${currentDate}T${startHour.trim()}`);

component.entryToEdit = { ...entryToEdit, start_date: expectedStartDate };
fixture.componentInstance.ngOnChanges();

component.entryForm.patchValue({ description: 'test' });

expect(component.dateToSubmit('start_date', 'start_hour')).toEqual(expectedStartDate);
});

it('should modify the start_date when start_hour has been modified', () => {
const startDate = new Date(mockCurrentDate);

Expand All @@ -445,19 +432,6 @@ describe('DetailsFieldsComponent', () => {
expect(component.dateToSubmit('start_date', 'start_hour')).toEqual(expectedStartDate);
});

it('should not modify the end_date when end_hour has not been modified', () => {
const currentDate = moment().format('YYYY-MM-DD');
const endHour = moment().subtract(3, 'hours').format('HH:mm:ss');
const expectedEndDate = new Date(`${currentDate}T${endHour.trim()}`);

component.entryToEdit = { ...entryToEdit, end_date: expectedEndDate };
fixture.componentInstance.ngOnChanges();

component.entryForm.patchValue({ description: 'test' });

expect(component.dateToSubmit('end_date', 'end_hour')).toEqual(expectedEndDate);
});

it('should modify the end_date when end_hour has been modified', () => {
const endDate = new Date(mockCurrentDate);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ export class DetailsFieldsComponent implements OnChanges, OnInit {
const updatedDate = new Date(`${entryFormDate}T${updatedHour.trim()}`).toISOString();
const initialDate = get(this.entryToEdit, date, updatedDate);
const initialHour = formatDate(get(this.entryToEdit, date, updatedDate), 'HH:mm', 'en');
const dateHasNotChanged = updatedHour === initialHour;
const dateHasNotChanged = (initialDate === updatedDate) && (updatedHour === initialHour);
const result = dateHasNotChanged ? initialDate : updatedDate;
return result;
}
Expand Down