@@ -141,8 +141,8 @@ describe('DetailsFieldsComponent', () => {
141
141
uri : 'ticketUri' ,
142
142
start_date : '' ,
143
143
end_date : '' ,
144
- start_hour : '00:00:10 ' ,
145
- end_hour : '00:00:11 ' ,
144
+ start_hour : '00:00' ,
145
+ end_hour : '00:00' ,
146
146
description : '' ,
147
147
technology : '' ,
148
148
} ;
@@ -176,22 +176,23 @@ describe('DetailsFieldsComponent', () => {
176
176
expect ( component . saveEntry . emit ) . toHaveBeenCalledTimes ( 0 ) ;
177
177
} ) ;
178
178
179
- [ { actionType : EntryActionTypes . CREATE_ENTRY_SUCCESS } , { actionType : EntryActionTypes . UPDATE_ENTRY_SUCCESS } ] . forEach (
180
- ( param ) => {
181
- it ( `cleanForm after an action type ${ param . actionType } is received` , ( ) => {
182
- const actionSubject = TestBed . inject ( ActionsSubject ) as ActionsSubject ;
183
- const action = {
184
- type : param . actionType ,
185
- } ;
186
- spyOn ( component , 'cleanForm' ) ;
179
+ [
180
+ { actionType : EntryActionTypes . CREATE_ENTRY_SUCCESS } ,
181
+ { actionType : EntryActionTypes . UPDATE_ENTRY_SUCCESS } ,
182
+ ] . forEach ( ( param ) => {
183
+ it ( `cleanForm after an action type ${ param . actionType } is received` , ( ) => {
184
+ const actionSubject = TestBed . inject ( ActionsSubject ) as ActionsSubject ;
185
+ const action = {
186
+ type : param . actionType ,
187
+ } ;
188
+ spyOn ( component , 'cleanForm' ) ;
187
189
188
- component . ngOnInit ( ) ;
189
- actionSubject . next ( action ) ;
190
+ component . ngOnInit ( ) ;
191
+ actionSubject . next ( action ) ;
190
192
191
- expect ( component . cleanForm ) . toHaveBeenCalled ( ) ;
192
- } ) ;
193
- }
194
- ) ;
193
+ expect ( component . cleanForm ) . toHaveBeenCalled ( ) ;
194
+ } ) ;
195
+ } ) ;
195
196
196
197
it ( 'on cleanFieldsForm the project_id and project_name should be kept' , ( ) => {
197
198
const entryFormValueExpected = {
@@ -295,8 +296,8 @@ describe('DetailsFieldsComponent', () => {
295
296
uri : '' ,
296
297
start_date : '2020-02-05' ,
297
298
end_date : '2020-02-05' ,
298
- start_hour : '00:00:01 ' ,
299
- end_hour : '00:01:01 ' ,
299
+ start_hour : '00:00' ,
300
+ end_hour : '00:01' ,
300
301
description : '' ,
301
302
technology : '' ,
302
303
} ) ;
@@ -309,8 +310,8 @@ describe('DetailsFieldsComponent', () => {
309
310
activity_id : 'a1' ,
310
311
technologies : [ ] ,
311
312
description : '' ,
312
- start_date : new Date ( '2020-02-05T00:00:01 ' ) . toISOString ( ) ,
313
- end_date : new Date ( '2020-02-05T00:01:01 ' ) . toISOString ( ) ,
313
+ start_date : new Date ( '2020-02-05T00:00:00 ' ) . toISOString ( ) ,
314
+ end_date : new Date ( '2020-02-05T00:01:00 ' ) . toISOString ( ) ,
314
315
uri : '' ,
315
316
timezone_offset : new Date ( ) . getTimezoneOffset ( ) ,
316
317
} ,
@@ -408,7 +409,7 @@ describe('DetailsFieldsComponent', () => {
408
409
activity_id : 'a1' ,
409
410
technologies : [ ] ,
410
411
description : '' ,
411
- start_date : new Date ( '2020-06-11T00:00:10 ' ) . toISOString ( ) ,
412
+ start_date : new Date ( '2020-06-11T00:00:00 ' ) . toISOString ( ) ,
412
413
uri : 'ticketUri' ,
413
414
timezone_offset : new Date ( ) . getTimezoneOffset ( ) ,
414
415
} ,
@@ -652,6 +653,58 @@ describe('DetailsFieldsComponent', () => {
652
653
componentToTest . onSubmit ( ) ;
653
654
expect ( toastrServiceStub . error ) . not . toHaveBeenCalled ( ) ;
654
655
} ) ;
656
+
657
+ it ( 'Should return a date in ISO format given a date, hour, minute, second and milisecond' , ( ) => {
658
+ const fakeDates = [
659
+ {
660
+ date : '2021-04-20' ,
661
+ hourAndMinutes : '10:00' ,
662
+ seconds : 20 ,
663
+ miliseconds : 100 ,
664
+ } ,
665
+ {
666
+ date : '2020-09-21' ,
667
+ hourAndMinutes : '08:00' ,
668
+ seconds : 10 ,
669
+ miliseconds : 100 ,
670
+ } ,
671
+ {
672
+ date : '2021-04-15' ,
673
+ hourAndMinutes : '23:00' ,
674
+ seconds : 0 ,
675
+ miliseconds : 0 ,
676
+ } ,
677
+ {
678
+ date : '2019-03-29' ,
679
+ hourAndMinutes : '12:00' ,
680
+ seconds : 30 ,
681
+ miliseconds : 400 ,
682
+ } ,
683
+ ] ;
684
+
685
+ const expectedISODates = [
686
+ new Date ( '2021-04-20T10:00:20.100' ) . toISOString ( ) ,
687
+ new Date ( '2020-09-21T08:00:10.100' ) . toISOString ( ) ,
688
+ new Date ( '2021-04-15T23:00:00.000' ) . toISOString ( ) ,
689
+ new Date ( '2019-03-29T12:00:30.400' ) . toISOString ( ) ,
690
+ ] ;
691
+
692
+ fakeDates . forEach ( ( { date, hourAndMinutes, seconds, miliseconds } , fakeDateIndex ) => {
693
+ const dateInISOFormat = component . getDateISOFormat ( date , hourAndMinutes , seconds , miliseconds ) ;
694
+ expect ( dateInISOFormat ) . toBe ( expectedISODates [ fakeDateIndex ] ) ;
695
+ } ) ;
696
+ } ) ;
697
+
698
+ it ( 'should return a number in ISO format given a normal number' , ( ) => {
699
+ const numbersForTest = [ 1 , 2 , 3 , 4 , 20 , 30 , 40 , 32 , 45 ] ;
700
+
701
+ const expectedISOFormatNumbers = [ '01' , '02' , '03' , '04' , '20' , '30' , '40' , '32' , '45' ] ;
702
+
703
+ numbersForTest . forEach ( ( currentNumber , numberIndex ) => {
704
+ const numberinISOFormat = component . getNumberInISOFormat ( currentNumber ) ;
705
+ expect ( numberinISOFormat ) . toBe ( expectedISOFormatNumbers [ numberIndex ] ) ;
706
+ } ) ;
707
+ } ) ;
655
708
/*
656
709
TODO As part of https://github.com/ioet/time-tracker-ui/issues/424 a new parameter was added to the details-field-component,
657
710
and now these couple of tests are failing. A solution to this error might be generate a Test Wrapper Component. More details here:
0 commit comments