Skip to content

Commit 414c4a6

Browse files
fix: TT 149 when edit date in update the date out (#640)
* fix: TT-149 When-edit-Date-In-update-the-Date-Out * fix: TT-149 When edit Date In update the Date Out * fix: TT-149 When edit Date In update the Date Out * fix: TT-149 When edit Date In update the Date Out * fix: TT-149 rename tests Co-authored-by: Sandro Castillo <[email protected]>
1 parent 7d593c8 commit 414c4a6

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed

src/app/modules/shared/components/details-fields/details-fields.component.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@
9090
aria-describedby="inputGroup-sizing-sm"
9191
[class.is-invalid]="start_date.invalid && start_date.touched"
9292
required
93+
(ngModelChange)="onStartDateChange($event)"
9394
/>
9495
</div>
9596

src/app/modules/shared/components/details-fields/details-fields.component.spec.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,31 @@ describe('DetailsFieldsComponent', () => {
443443
expect(component.projectSelected.emit).toHaveBeenCalledWith(data);
444444
});
445445

446+
it('on selected start_date should change end_date', () => {
447+
const expectedStartDate = '2020-02-05';
448+
449+
component.onStartDateChange(expectedStartDate);
450+
fixture.detectChanges();
451+
const endDateInput: HTMLInputElement = fixture.debugElement.nativeElement.querySelector('#end_date');
452+
453+
expect(endDateInput.value).toEqual(expectedStartDate);
454+
});
455+
456+
it('on selected end_date should not change start_date', () => {
457+
const expectedStartDate = '2020-02-05';
458+
const expectedEndDate = '2020-02-06';
459+
460+
component.ngOnInit();
461+
fixture.detectChanges();
462+
const startDateInput: HTMLInputElement = fixture.debugElement.nativeElement.querySelector('#start_date');
463+
const endDateInput: HTMLInputElement = fixture.debugElement.nativeElement.querySelector('#end_date');
464+
startDateInput.value = expectedStartDate;
465+
endDateInput.value = expectedEndDate;
466+
endDateInput.dispatchEvent(new Event('#end_date'));
467+
468+
expect(endDateInput.value).not.toEqual(startDateInput.value);
469+
expect(startDateInput.value).toEqual(expectedStartDate);
470+
});
446471
/*
447472
TODO As part of https://github.com/ioet/time-tracker-ui/issues/424 a new parameter was added to the details-field-component,
448473
and now these couple of tests are failing. A solution to this error might be generate a Test Wrapper Component. More details here:

src/app/modules/shared/components/details-fields/details-fields.component.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,10 @@ export class DetailsFieldsComponent implements OnChanges, OnInit {
124124
});
125125
}
126126

127+
onStartDateChange($event: string) {
128+
this.end_date.setValue($event);
129+
}
130+
127131
ngOnChanges(): void {
128132
this.goingToWorkOnThis = this.entryToEdit ? this.entryToEdit.running : false;
129133
this.shouldRestartEntry = false;

0 commit comments

Comments
 (0)