Skip to content
Merged
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 @@ -90,6 +90,7 @@
aria-describedby="inputGroup-sizing-sm"
[class.is-invalid]="start_date.invalid && start_date.touched"
required
(ngModelChange)="onStartDateChange($event)"
/>
</div>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,31 @@ describe('DetailsFieldsComponent', () => {
expect(component.projectSelected.emit).toHaveBeenCalledWith(data);
});

it('on selected start_date should change end_date', () => {
const expectedStartDate = '2020-02-05';

component.onStartDateChange(expectedStartDate);
fixture.detectChanges();
const endDateInput: HTMLInputElement = fixture.debugElement.nativeElement.querySelector('#end_date');

expect(endDateInput.value).toEqual(expectedStartDate);
});

it('on selected end_date should not change start_date', () => {
const expectedStartDate = '2020-02-05';
const expectedEndDate = '2020-02-06';

component.ngOnInit();
fixture.detectChanges();
const startDateInput: HTMLInputElement = fixture.debugElement.nativeElement.querySelector('#start_date');
const endDateInput: HTMLInputElement = fixture.debugElement.nativeElement.querySelector('#end_date');
startDateInput.value = expectedStartDate;
endDateInput.value = expectedEndDate;
endDateInput.dispatchEvent(new Event('#end_date'));

expect(endDateInput.value).not.toEqual(startDateInput.value);
expect(startDateInput.value).toEqual(expectedStartDate);
});
/*
TODO As part of https://github.com/ioet/time-tracker-ui/issues/424 a new parameter was added to the details-field-component,
and now these couple of tests are failing. A solution to this error might be generate a Test Wrapper Component. More details here:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ export class DetailsFieldsComponent implements OnChanges, OnInit {
});
}

onStartDateChange($event: string) {
this.end_date.setValue($event);
}

ngOnChanges(): void {
this.goingToWorkOnThis = this.entryToEdit ? this.entryToEdit.running : false;
this.shouldRestartEntry = false;
Expand Down