1
1
import * as actions from './entry.actions' ;
2
2
import * as moment from 'moment' ;
3
3
import { TimeEntriesTimeRange } from '../models/time-entries-time-range' ;
4
+ import { Entry } from '../../shared/models' ;
4
5
5
6
describe ( '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
+ } ) ;
6
17
7
18
8
19
it ( 'SwitchTimeEntry type is EntryActionTypes.SWITCH_TIME_ENTRY' , ( ) => {
@@ -66,13 +77,7 @@ describe('Actions for Entries', () => {
66
77
} ) ;
67
78
68
79
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 ) ;
76
81
expect ( updateActiveEntrySuccess . type ) . toEqual ( actions . EntryActionTypes . UPDATE_ENTRY_SUCCESS ) ;
77
82
} ) ;
78
83
@@ -82,13 +87,7 @@ describe('Actions for Entries', () => {
82
87
} ) ;
83
88
84
89
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 ) ;
92
91
expect ( action . type ) . toEqual ( actions . EntryActionTypes . UPDATE_ENTRY_RUNNING ) ;
93
92
} ) ;
94
93
@@ -111,4 +110,19 @@ describe('Actions for Entries', () => {
111
110
const action = new actions . LoadEntriesByTimeRangeFail ( ) ;
112
111
expect ( action . type ) . toEqual ( actions . EntryActionTypes . LOAD_ENTRIES_BY_TIME_RANGE_FAIL ) ;
113
112
} ) ;
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
+ } ) ;
114
128
} ) ;
0 commit comments