Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
fix: TT-149 When-edit-Date-In-update-the-Date-Out
  • Loading branch information
wobravo authored and scastillo-jp committed Feb 24, 2021
commit 3d41cbe9e574f65b2d63fa09fb3091dae07a28a4
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)="onInitialDatepickerUpdated($event)"
/>
</div>

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

it('on Selected Initial Date should change end date', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not critical. But we can use Start date reference instead of initial date

const expectedDate = '2020-02-05';

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

expect(endDateInput.value).toEqual(expectedDate);

});

it('on Selected End Date should not change initial date', () => {
const expectedInitialDate = '2020-02-05';
const expectedEndDate = '2020-02-06';
component.onInitialDatepickerUpdated(expectedInitialDate);
fixture.detectChanges();
const endDateInput: HTMLInputElement = fixture.debugElement.nativeElement.querySelector('#end_date');

expect(endDateInput.value).toEqual(expectedInitialDate);

});

fit('should be ok', () => {
component.ngOnInit();
fixture.detectChanges();
const endDateInput: HTMLInputElement = fixture.debugElement.nativeElement.querySelector('#end_date');
endDateInput.value = '2021-02-21';
endDateInput.dispatchEvent(new Event('#end_date'));

expect(endDateInput.value).toBe('2021-02-21');
});

/*
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,14 @@ export class DetailsFieldsComponent implements OnChanges, OnInit {
});
}

onInitialDatepickerUpdated($event: string) {
console.log($event);
this.end_date.setValue($event);

}



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