11import * as actions from './entry.actions' ;
22import * as moment from 'moment' ;
33import { TimeEntriesTimeRange } from '../models/time-entries-time-range' ;
4+ import { Entry } from '../../shared/models' ;
45
56describe ( 'Actions for Entries' , ( ) => {
7+ let entry : Entry ;
8+ beforeEach ( ( ) => {
9+ entry = {
10+ id : '1' ,
11+ start_date : new Date ( ) ,
12+ end_date : new Date ( ) ,
13+ activity_id : '' ,
14+ technologies : [ 'abc' , 'abc' ] ,
15+ } ;
16+ } ) ;
617
718
819 it ( 'SwitchTimeEntry type is EntryActionTypes.SWITCH_TIME_ENTRY' , ( ) => {
@@ -66,13 +77,7 @@ describe('Actions for Entries', () => {
6677 } ) ;
6778
6879 it ( 'UpdateEntrySuccess type is EntryActionTypes.UDPATE_ENTRY_SUCCESS' , ( ) => {
69- const updateActiveEntrySuccess = new actions . UpdateEntrySuccess ( {
70- id : '1' ,
71- start_date : new Date ( ) ,
72- end_date : new Date ( ) ,
73- activity_id : '' ,
74- technologies : [ 'abc' , 'abc' ] ,
75- } ) ;
80+ const updateActiveEntrySuccess = new actions . UpdateEntrySuccess ( entry ) ;
7681 expect ( updateActiveEntrySuccess . type ) . toEqual ( actions . EntryActionTypes . UPDATE_ENTRY_SUCCESS ) ;
7782 } ) ;
7883
@@ -82,13 +87,7 @@ describe('Actions for Entries', () => {
8287 } ) ;
8388
8489 it ( 'UpdateActiveEntry type is EntryActionTypes.UDPATE_ENTRY_FAIL' , ( ) => {
85- const action = new actions . UpdateEntryRunning ( {
86- id : '1' ,
87- start_date : new Date ( ) ,
88- end_date : new Date ( ) ,
89- activity_id : '' ,
90- technologies : [ 'abc' , 'abc' ] ,
91- } ) ;
90+ const action = new actions . UpdateEntryRunning ( entry ) ;
9291 expect ( action . type ) . toEqual ( actions . EntryActionTypes . UPDATE_ENTRY_RUNNING ) ;
9392 } ) ;
9493
@@ -111,4 +110,19 @@ describe('Actions for Entries', () => {
111110 const action = new actions . LoadEntriesByTimeRangeFail ( ) ;
112111 expect ( action . type ) . toEqual ( actions . EntryActionTypes . LOAD_ENTRIES_BY_TIME_RANGE_FAIL ) ;
113112 } ) ;
113+
114+ it ( 'RestartEntry type is EntryActionTypes.RESTART_ENTRY' , ( ) => {
115+ const action = new actions . RestartEntry ( entry ) ;
116+ expect ( action . type ) . toEqual ( actions . EntryActionTypes . RESTART_ENTRY ) ;
117+ } ) ;
118+
119+ it ( 'RestartEntrySuccess type is EntryActionTypes.RESTART_ENTRY_SUCCESS' , ( ) => {
120+ const action = new actions . RestartEntrySuccess ( entry ) ;
121+ expect ( action . type ) . toEqual ( actions . EntryActionTypes . RESTART_ENTRY_SUCCESS ) ;
122+ } ) ;
123+
124+ it ( 'RestartEntryFail type is EntryActionTypes.RESTART_ENTRY_FAIL' , ( ) => {
125+ const action = new actions . RestartEntryFail ( 'error' ) ;
126+ expect ( action . type ) . toEqual ( actions . EntryActionTypes . RESTART_ENTRY_FAIL ) ;
127+ } ) ;
114128} ) ;
0 commit comments