@@ -9,11 +9,12 @@ import * as moment from 'moment';
9
9
import { ToastrModule , ToastrService } from 'ngx-toastr' ;
10
10
import { Observable , of , throwError } from 'rxjs' ;
11
11
import { TimeEntriesTimeRange } from '../models/time-entries-time-range' ;
12
- import { EntryService } from '../services/entry.service' ;
12
+ import { EntryService , MAX_NUMBER_OF_ENTRIES_FOR_REPORTS } from '../services/entry.service' ;
13
13
import { INFO_SAVED_SUCCESSFULLY } from './../../shared/messages' ;
14
14
import { EntryActionTypes , SwitchTimeEntry , DeleteEntry , CreateEntry } from './entry.actions' ;
15
15
import { EntryEffects } from './entry.effects' ;
16
16
17
+
17
18
describe ( 'TimeEntryActionEffects' , ( ) => {
18
19
19
20
let actions$ : Observable < Action > ;
@@ -385,7 +386,7 @@ describe('TimeEntryActionEffects', () => {
385
386
spyOn ( toastrService , 'success' ) ;
386
387
387
388
effects . updateCurrentOrLastEntry$ . subscribe ( action => {
388
- expect ( toastrService . success ) . toHaveBeenCalledWith ( 'You change the time-in successfully' ) ;
389
+ expect ( toastrService . success ) . toHaveBeenCalledWith ( 'You changed the time-in successfully' ) ;
389
390
expect ( action . type ) . toEqual ( EntryActionTypes . UPDATE_ENTRY_RUNNING ) ;
390
391
} ) ;
391
392
} ) ;
@@ -399,4 +400,26 @@ describe('TimeEntryActionEffects', () => {
399
400
} ) ;
400
401
} ) ;
401
402
403
+ it ( 'should show a warning when maximum number of entries is received' , async ( ) => {
404
+ const timeRange : TimeEntriesTimeRange = { start_date : moment ( new Date ( ) ) , end_date : moment ( new Date ( ) ) } ;
405
+ const userId = '*' ;
406
+ const entries = [ ] ;
407
+ for ( let i = 0 ; i < MAX_NUMBER_OF_ENTRIES_FOR_REPORTS ; i ++ ) {
408
+ entries . push ( { ...entry , id : i . toString ( ) } ) ;
409
+ }
410
+
411
+ const serviceSpy = spyOn ( service , 'loadEntriesByTimeRange' ) ;
412
+ serviceSpy . and . returnValue ( of ( entries ) ) ;
413
+ spyOn ( toastrService , 'warning' ) ;
414
+
415
+ actions$ = of ( { type : EntryActionTypes . LOAD_ENTRIES_BY_TIME_RANGE , timeRange, userId } ) ;
416
+
417
+ effects . loadEntriesByTimeRange$ . subscribe ( action => {
418
+ expect ( toastrService . warning ) . toHaveBeenCalledWith (
419
+ 'Still loading. Limit of ' + MAX_NUMBER_OF_ENTRIES_FOR_REPORTS +
420
+ ' entries reached, try filtering the request by users or date.' +
421
+ ' Some information may be missing.'
422
+ ) ;
423
+ } ) ;
424
+ } ) ;
402
425
} ) ;
0 commit comments