1- import { AutocompleteLibModule } from 'angular-ng-autocomplete' ;
21import { formatDate } from '@angular/common' ;
32import { async , ComponentFixture , TestBed } from '@angular/core/testing' ;
43import { FormsModule , ReactiveFormsModule } from '@angular/forms' ;
54import { ActionsSubject } from '@ngrx/store' ;
65import { MockStore , provideMockStore } from '@ngrx/store/testing' ;
6+ import { AutocompleteLibModule } from 'angular-ng-autocomplete' ;
7+ import * as moment from 'moment' ;
78import { IndividualConfig , ToastrService } from 'ngx-toastr' ;
89import { getCreateError , getUpdateError } from 'src/app/modules/time-clock/store/entry.selectors' ;
910import { ProjectState } from '../../../customer-management/components/projects/components/store/project.reducer' ;
@@ -17,6 +18,7 @@ import { TechnologiesComponent } from './../technologies/technologies.component'
1718import { DetailsFieldsComponent } from './details-fields.component' ;
1819import { SaveEntryEvent } from './save-entry-event' ;
1920
21+
2022describe ( 'DetailsFieldsComponent' , ( ) => {
2123 type Merged = TechnologyState & ProjectState & EntryState ;
2224 let component : DetailsFieldsComponent ;
@@ -304,16 +306,15 @@ describe('DetailsFieldsComponent', () => {
304306 expect ( component . saveEntry . emit ) . toHaveBeenCalledWith ( data ) ;
305307 } ) ;
306308
307- // TODO Fix this test since it is failing.
308- // it('displays error message when the date selected is in the future', () => {
309- // spyOn(toastrServiceStub, 'error');
309+ it ( 'displays error message when the date selected is in the future' , ( ) => {
310+ spyOn ( toastrServiceStub , 'error' ) ;
310311
311- // const futureDate = moment().add(1, 'days').format('YYYY-MM-DD');
312- // component.entryForm.setValue({ ...formValues, entry_date: futureDate });
313- // component.onSubmit();
312+ const futureDate = moment ( ) . add ( 1 , 'days' ) . format ( 'YYYY-MM-DD' ) ;
313+ component . entryForm . setValue ( { ...formValues , entry_date : futureDate } ) ;
314+ component . onSubmit ( ) ;
314315
315- // expect(toastrServiceStub.error).toHaveBeenCalled();
316- // });
316+ expect ( toastrServiceStub . error ) . toHaveBeenCalled ( ) ;
317+ } ) ;
317318
318319 /*
319320 TODO As part of https://github.com/ioet/time-tracker-ui/issues/424 a new parameter was added to the details-field-component,
0 commit comments