Skip to content

Commit 9cff77c

Browse files
authored
Merge 4045b4c into e78badb
2 parents e78badb + 4045b4c commit 9cff77c

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@
9191
[class.is-invalid]="start_date.invalid && start_date.touched"
9292
required
9393
(ngModelChange)="onStartDateChange($event)"
94+
[max]="getCurrentDate()"
95+
onkeydown="return false"
9496
/>
9597
</div>
9698

@@ -118,6 +120,8 @@
118120
aria-describedby="inputGroup-sizing-sm"
119121
[class.is-invalid]="end_date.invalid && end_date.touched"
120122
required
123+
[max]="getCurrentDate()"
124+
onkeydown="return false"
121125
/>
122126
</div>
123127

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
@@ -468,6 +468,31 @@ describe('DetailsFieldsComponent', () => {
468468
expect(endDateInput.value).not.toEqual(startDateInput.value);
469469
expect(startDateInput.value).toEqual(expectedStartDate);
470470
});
471+
472+
it('on get current date should return expected date', () => {
473+
const expectedDate = new Date().toISOString().split('T')[0];
474+
475+
expect(component.getCurrentDate()).toEqual(expectedDate);
476+
});
477+
478+
it('on the input with id #start_date we could get the id and max value', () => {
479+
fixture.detectChanges();
480+
const expectedDate = new Date().toISOString().split('T')[0];
481+
const startDateInput: HTMLInputElement = fixture.debugElement.
482+
nativeElement.querySelector(`input[id="start_date"],input[max="${component.getCurrentDate()}"]`);
483+
484+
expect(startDateInput.id).toEqual('start_date');
485+
expect(startDateInput.max).toEqual(expectedDate);
486+
});
487+
488+
it('on the input with id #end_date we could get the current Date ', () => {
489+
fixture.detectChanges();
490+
const expectedDate = new Date().toISOString().split('T')[0];
491+
const endDateInput = fixture.debugElement.nativeElement.querySelector('[id=end_date]');
492+
493+
expect(endDateInput.id).toEqual('end_date');
494+
expect(endDateInput.max).toEqual(expectedDate);
495+
});
471496
/*
472497
TODO As part of https://github.com/ioet/time-tracker-ui/issues/424 a new parameter was added to the details-field-component,
473498
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
@@ -171,6 +171,10 @@ export class DetailsFieldsComponent implements OnChanges, OnInit {
171171
this.selectedTechnologies = $event;
172172
}
173173

174+
getCurrentDate(): string {
175+
return new Date().toISOString().split('T')[0];
176+
}
177+
174178
get project_id() {
175179
return this.entryForm.get('project_id');
176180
}

0 commit comments

Comments
 (0)