1
- import { AutocompleteLibModule } from 'angular-ng-autocomplete' ;
2
1
import { formatDate } from '@angular/common' ;
3
2
import { async , ComponentFixture , TestBed } from '@angular/core/testing' ;
4
3
import { FormsModule , ReactiveFormsModule } from '@angular/forms' ;
5
4
import { ActionsSubject } from '@ngrx/store' ;
6
5
import { MockStore , provideMockStore } from '@ngrx/store/testing' ;
6
+ import { AutocompleteLibModule } from 'angular-ng-autocomplete' ;
7
+ import * as moment from 'moment' ;
7
8
import { IndividualConfig , ToastrService } from 'ngx-toastr' ;
8
9
import { getCreateError , getUpdateError } from 'src/app/modules/time-clock/store/entry.selectors' ;
9
10
import { ProjectState } from '../../../customer-management/components/projects/components/store/project.reducer' ;
@@ -17,6 +18,7 @@ import { TechnologiesComponent } from './../technologies/technologies.component'
17
18
import { DetailsFieldsComponent } from './details-fields.component' ;
18
19
import { SaveEntryEvent } from './save-entry-event' ;
19
20
21
+
20
22
describe ( 'DetailsFieldsComponent' , ( ) => {
21
23
type Merged = TechnologyState & ProjectState & EntryState ;
22
24
let component : DetailsFieldsComponent ;
@@ -304,16 +306,15 @@ describe('DetailsFieldsComponent', () => {
304
306
expect ( component . saveEntry . emit ) . toHaveBeenCalledWith ( data ) ;
305
307
} ) ;
306
308
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' ) ;
310
311
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 ( ) ;
314
315
315
- // expect(toastrServiceStub.error).toHaveBeenCalled();
316
- // });
316
+ expect ( toastrServiceStub . error ) . toHaveBeenCalled ( ) ;
317
+ } ) ;
317
318
318
319
/*
319
320
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