Skip to content

Commit 3d41cbe

Browse files
wobravoscastillo-jp
authored andcommitted
fix: TT-149 When-edit-Date-In-update-the-Date-Out
1 parent 7d593c8 commit 3d41cbe

File tree

3 files changed

+41
-0
lines changed

3 files changed

+41
-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)="onInitialDatepickerUpdated($event)"
9394
/>
9495
</div>
9596

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

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

446+
it('on Selected Initial Date should change end date', () => {
447+
const expectedDate = '2020-02-05';
448+
449+
component.onInitialDatepickerUpdated(expectedDate);
450+
fixture.detectChanges();
451+
const endDateInput: HTMLInputElement = fixture.debugElement.nativeElement.querySelector('#end_date');
452+
453+
expect(endDateInput.value).toEqual(expectedDate);
454+
455+
});
456+
457+
it('on Selected End Date should not change initial date', () => {
458+
const expectedInitialDate = '2020-02-05';
459+
const expectedEndDate = '2020-02-06';
460+
component.onInitialDatepickerUpdated(expectedInitialDate);
461+
fixture.detectChanges();
462+
const endDateInput: HTMLInputElement = fixture.debugElement.nativeElement.querySelector('#end_date');
463+
464+
expect(endDateInput.value).toEqual(expectedInitialDate);
465+
466+
});
467+
468+
fit('should be ok', () => {
469+
component.ngOnInit();
470+
fixture.detectChanges();
471+
const endDateInput: HTMLInputElement = fixture.debugElement.nativeElement.querySelector('#end_date');
472+
endDateInput.value = '2021-02-21';
473+
endDateInput.dispatchEvent(new Event('#end_date'));
474+
475+
expect(endDateInput.value).toBe('2021-02-21');
476+
});
477+
446478
/*
447479
TODO As part of https://github.com/ioet/time-tracker-ui/issues/424 a new parameter was added to the details-field-component,
448480
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: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,14 @@ export class DetailsFieldsComponent implements OnChanges, OnInit {
124124
});
125125
}
126126

127+
onInitialDatepickerUpdated($event: string) {
128+
console.log($event);
129+
this.end_date.setValue($event);
130+
131+
}
132+
133+
134+
127135
ngOnChanges(): void {
128136
this.goingToWorkOnThis = this.entryToEdit ? this.entryToEdit.running : false;
129137
this.shouldRestartEntry = false;

0 commit comments

Comments
 (0)