11import { INFO_SAVED_SUCCESSFULLY } from './../../shared/messages' ;
2- import { TestBed } from '@angular/core/testing' ;
3- import { provideMockActions } from '@ngrx/effects/testing' ;
4- import { EntryEffects } from './entry.effects' ;
5- import { Observable , of , throwError } from 'rxjs' ;
6- import { HttpClientTestingModule } from '@angular/common/http/testing' ;
2+ import { TestBed } from '@angular/core/testing' ;
3+ import { provideMockActions } from '@ngrx/effects/testing' ;
4+ import { EntryEffects } from './entry.effects' ;
5+ import { Observable , of , throwError } from 'rxjs' ;
6+ import { HttpClientTestingModule } from '@angular/common/http/testing' ;
77import { ToastrModule , ToastrService } from 'ngx-toastr' ;
8- import { Action } from '@ngrx/store' ;
9- import { DatePipe } from '@angular/common' ;
10- import { EntryActionTypes } from './entry.actions' ;
11- import { EntryService } from '../services/entry.service' ;
12- import { TimeEntriesTimeRange } from '../models/time-entries-time-range' ;
8+ import { Action } from '@ngrx/store' ;
9+ import { DatePipe } from '@angular/common' ;
10+ import { EntryActionTypes } from './entry.actions' ;
11+ import { EntryService } from '../services/entry.service' ;
12+ import { TimeEntriesTimeRange } from '../models/time-entries-time-range' ;
1313import * as moment from 'moment' ;
1414
1515describe ( 'TimeEntryActionEffects' , ( ) => {
@@ -38,7 +38,7 @@ describe('TimeEntryActionEffects', () => {
3838 expect ( effects ) . toBeTruthy ( ) ;
3939 } ) ;
4040
41- it ( 'returns an action with type LOAD_ENTRIES_SUMMARY_SUCCESS when the service returns a value' , ( ) => {
41+ it ( 'returns an action with type LOAD_ENTRIES_SUMMARY_SUCCESS when the service returns a value' , ( ) => {
4242 actions$ = of ( { type : EntryActionTypes . LOAD_ENTRIES_SUMMARY } ) ;
4343 const serviceSpy = spyOn ( service , 'summary' ) ;
4444 serviceSpy . and . returnValue ( of ( { } ) ) ;
@@ -48,7 +48,7 @@ describe('TimeEntryActionEffects', () => {
4848 } ) ;
4949 } ) ;
5050
51- it ( 'returns an action with type LOAD_ENTRIES_SUMMARY_FAIL when the service fails' , ( ) => {
51+ it ( 'returns an action with type LOAD_ENTRIES_SUMMARY_FAIL when the service fails' , ( ) => {
5252 actions$ = of ( { type : EntryActionTypes . LOAD_ENTRIES_SUMMARY } ) ;
5353 spyOn ( service , 'summary' ) . and . returnValue ( throwError ( 'any error' ) ) ;
5454
@@ -57,9 +57,10 @@ describe('TimeEntryActionEffects', () => {
5757 } ) ;
5858 } ) ;
5959
60- it ( 'When the service returns a value, then LOAD_ENTRIES_BY_TIME_RANGE_SUCCESS should be triggered' , ( ) => {
61- const timeRange : TimeEntriesTimeRange = { start_date : moment ( new Date ( ) ) , end_date : moment ( new Date ( ) ) , user_id : '*' } ;
62- actions$ = of ( { type : EntryActionTypes . LOAD_ENTRIES_BY_TIME_RANGE , timeRange} ) ;
60+ it ( 'When the service returns a value, then LOAD_ENTRIES_BY_TIME_RANGE_SUCCESS should be triggered' , ( ) => {
61+ const timeRange : TimeEntriesTimeRange = { start_date : moment ( new Date ( ) ) , end_date : moment ( new Date ( ) ) } ;
62+ const userId = '*' ;
63+ actions$ = of ( { type : EntryActionTypes . LOAD_ENTRIES_BY_TIME_RANGE , timeRange, userId} ) ;
6364 const serviceSpy = spyOn ( service , 'loadEntriesByTimeRange' ) ;
6465 serviceSpy . and . returnValue ( of ( [ ] ) ) ;
6566
@@ -70,13 +71,14 @@ describe('TimeEntryActionEffects', () => {
7071 } ) ;
7172
7273 it ( 'When the service fails, then LOAD_ENTRIES_BY_TIME_RANGE_FAIL should be triggered' , async ( ) => {
73- const timeRange : TimeEntriesTimeRange = { start_date : moment ( new Date ( ) ) , end_date : moment ( new Date ( ) ) , user_id : '*' } ;
74- actions$ = of ( { type : EntryActionTypes . LOAD_ENTRIES_BY_TIME_RANGE , timeRange} ) ;
75- spyOn ( service , 'loadEntriesByTimeRange' ) . and . returnValue ( throwError ( 'any error' ) ) ;
74+ const timeRange : TimeEntriesTimeRange = { start_date : moment ( new Date ( ) ) , end_date : moment ( new Date ( ) ) } ;
75+ const userId = '*' ;
76+ actions$ = of ( { type : EntryActionTypes . LOAD_ENTRIES_BY_TIME_RANGE , timeRange, userId} ) ;
77+ spyOn ( service , 'loadEntriesByTimeRange' ) . and . returnValue ( throwError ( 'any error' ) ) ;
7678
77- effects . loadEntriesByTimeRange$ . subscribe ( action => {
78- expect ( action . type ) . toEqual ( EntryActionTypes . LOAD_ENTRIES_BY_TIME_RANGE_FAIL ) ;
79- } ) ;
79+ effects . loadEntriesByTimeRange$ . subscribe ( action => {
80+ expect ( action . type ) . toEqual ( EntryActionTypes . LOAD_ENTRIES_BY_TIME_RANGE_FAIL ) ;
81+ } ) ;
8082 } ) ;
8183
8284 it ( 'returns a LOAD_ACTIVE_ENTRY_SUCCESS when the entry that is running it is in the same day' , async ( ) => {
@@ -92,7 +94,7 @@ describe('TimeEntryActionEffects', () => {
9294
9395 it ( 'returns a LOAD_ACTIVE_ENTRY_SUCCESS when the entry that is running it is in the same day' , async ( ) => {
9496 const startDateInPast = new Date ( ) ;
95- startDateInPast . setDate ( startDateInPast . getDate ( ) - 5 ) ;
97+ startDateInPast . setDate ( startDateInPast . getDate ( ) - 5 ) ;
9698 const activeEntry = { start_date : startDateInPast } ;
9799 actions$ = of ( { type : EntryActionTypes . LOAD_ACTIVE_ENTRY , activeEntry} ) ;
98100 const serviceSpy = spyOn ( service , 'loadActiveEntry' ) ;
0 commit comments