@@ -9,10 +9,12 @@ import * as moment from 'moment';
99import { ToastrModule , ToastrService } from 'ngx-toastr' ;
1010import { Observable , of , throwError } from 'rxjs' ;
1111import { 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' ;
1313import { INFO_SAVED_SUCCESSFULLY } from './../../shared/messages' ;
1414import { EntryActionTypes , SwitchTimeEntry , DeleteEntry , CreateEntry } from './entry.actions' ;
1515import { EntryEffects } from './entry.effects' ;
16+ import { stringify } from 'querystring' ;
17+ import { isString } from 'util' ;
1618
1719describe ( 'TimeEntryActionEffects' , ( ) => {
1820
@@ -385,7 +387,7 @@ describe('TimeEntryActionEffects', () => {
385387 spyOn ( toastrService , 'success' ) ;
386388
387389 effects . updateCurrentOrLastEntry$ . subscribe ( action => {
388- expect ( toastrService . success ) . toHaveBeenCalledWith ( 'You change the time-in successfully' ) ;
390+ expect ( toastrService . success ) . toHaveBeenCalledWith ( 'You changed the time-in successfully' ) ;
389391 expect ( action . type ) . toEqual ( EntryActionTypes . UPDATE_ENTRY_RUNNING ) ;
390392 } ) ;
391393 } ) ;
@@ -399,4 +401,26 @@ describe('TimeEntryActionEffects', () => {
399401 } ) ;
400402 } ) ;
401403
404+ fit ( 'should show a warning when maximum number of entries is received' , async ( ) => {
405+ const timeRange : TimeEntriesTimeRange = { start_date : moment ( new Date ( ) ) , end_date : moment ( new Date ( ) ) } ;
406+ const userId = '*' ;
407+ const entries = [ ] ;
408+ for ( let i = 0 ; i < MAX_NUMBER_OF_ENTRIES_FOR_REPORTS ; i ++ ) {
409+ entries . push ( { ...entry , id : i . toString ( ) } ) ;
410+ }
411+
412+ const serviceSpy = spyOn ( service , 'loadEntriesByTimeRange' ) ;
413+ serviceSpy . and . returnValue ( of ( entries ) ) ;
414+ spyOn ( toastrService , 'warning' ) ;
415+
416+ actions$ = of ( { type : EntryActionTypes . LOAD_ENTRIES_BY_TIME_RANGE , timeRange, userId } ) ;
417+
418+ effects . loadEntriesByTimeRange$ . subscribe ( action => {
419+ expect ( toastrService . warning ) . toHaveBeenCalledWith (
420+ 'Still loading. Limit of ' + MAX_NUMBER_OF_ENTRIES_FOR_REPORTS +
421+ ' entries reached, try filtering the request by users or date.' +
422+ ' Some information may be missing.'
423+ ) ;
424+ } ) ;
425+ } ) ;
402426} ) ;
0 commit comments