@@ -128,22 +128,22 @@ describe('DetailsFieldsComponent', () => {
128
128
expect ( component ) . toBeTruthy ( ) ;
129
129
} ) ;
130
130
131
- it ( 'onClearedComponent project id and name it is set to empty' , ( ) => {
131
+ it ( 'onClearedComponent project id and name are set to empty' , ( ) => {
132
132
component . onClearedComponent ( null ) ;
133
133
134
134
expect ( component . project_id . value ) . toBe ( '' ) ;
135
135
expect ( component . project_name . value ) . toBe ( '' ) ;
136
136
} ) ;
137
137
138
- it ( 'onSelectedProject project id and name it is set using event data' , ( ) => {
138
+ it ( 'onSelectedProject project id and name are set using event data' , ( ) => {
139
139
spyOn ( component . entryForm , 'patchValue' ) ;
140
140
141
141
component . onSelectedProject ( { id : 'id' , search_field : 'foo' } ) ;
142
142
143
143
expect ( component . entryForm . patchValue ) . toHaveBeenCalledWith ( { project_id : 'id' , project_name : 'foo' , } ) ;
144
144
} ) ;
145
145
146
- it ( 'if form is invalid then no save is emited' , ( ) => {
146
+ it ( 'if form is invalid then saveEntry is not emited' , ( ) => {
147
147
spyOn ( component . saveEntry , 'emit' ) ;
148
148
149
149
component . onSubmit ( ) ;
@@ -172,6 +172,7 @@ describe('DetailsFieldsComponent', () => {
172
172
it ( 'should emit ngOnChange without data' , ( ) => {
173
173
component . entryToEdit = null ;
174
174
component . ngOnChanges ( ) ;
175
+ expect ( component . shouldRestartEntry ) . toBeFalse ( ) ;
175
176
expect ( component . entryForm . value ) . toEqual ( initialData ) ;
176
177
} ) ;
177
178
@@ -243,6 +244,7 @@ describe('DetailsFieldsComponent', () => {
243
244
} ,
244
245
shouldRestartEntry : false
245
246
} ;
247
+
246
248
expect ( component . saveEntry . emit ) . toHaveBeenCalledWith ( data ) ;
247
249
} ) ;
248
250
@@ -298,14 +300,23 @@ describe('DetailsFieldsComponent', () => {
298
300
fixture . componentInstance . ngOnChanges ( ) ;
299
301
300
302
expect ( component . goingToWorkOnThis ) . toBeFalse ( ) ;
303
+ expect ( component . shouldRestartEntry ) . toBeFalse ( ) ;
301
304
} ) ;
302
305
303
- it ( 'when editing entry that already finished, then the entry should not be marked as running ' , ( ) => {
304
- component . entryToEdit = { ...entryToEdit , running : false } ;
306
+ it ( 'when editing entry is running, shouldRestartEntry should be false ' , ( ) => {
307
+ component . entryToEdit = { ...entryToEdit , running : true } ;
305
308
306
309
fixture . componentInstance . ngOnChanges ( ) ;
307
310
308
- expect ( component . goingToWorkOnThis ) . toBeFalse ( ) ;
311
+ expect ( component . goingToWorkOnThis ) . toBeTrue ( ) ;
312
+ expect ( component . shouldRestartEntry ) . toBeFalse ( ) ;
313
+ } ) ;
314
+
315
+ it ( 'when editing entry change to going to work on this shouldRestartEntry should be true' , ( ) => {
316
+ component . onGoingToWorkOnThisChange ( { currentTarget : { checked : true } } ) ;
317
+
318
+ expect ( component . goingToWorkOnThis ) . toBeTrue ( ) ;
319
+ expect ( component . shouldRestartEntry ) . toBeTrue ( ) ;
309
320
} ) ;
310
321
311
322
it ( 'when submitting a entry that is currently running, the end date should not be sent ' , ( ) => {
@@ -328,6 +339,7 @@ describe('DetailsFieldsComponent', () => {
328
339
} ,
329
340
shouldRestartEntry : false
330
341
} ;
342
+
331
343
expect ( component . saveEntry . emit ) . toHaveBeenCalledWith ( data ) ;
332
344
} ) ;
333
345
0 commit comments