@@ -141,8 +141,8 @@ describe('DetailsFieldsComponent', () => {
141141 uri : 'ticketUri' ,
142142 start_date : '' ,
143143 end_date : '' ,
144- start_hour : '00:00:10 ' ,
145- end_hour : '00:00:11 ' ,
144+ start_hour : '00:00' ,
145+ end_hour : '00:00' ,
146146 description : '' ,
147147 technology : '' ,
148148 } ;
@@ -176,22 +176,23 @@ describe('DetailsFieldsComponent', () => {
176176 expect ( component . saveEntry . emit ) . toHaveBeenCalledTimes ( 0 ) ;
177177 } ) ;
178178
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' ) ;
187189
188- component . ngOnInit ( ) ;
189- actionSubject . next ( action ) ;
190+ component . ngOnInit ( ) ;
191+ actionSubject . next ( action ) ;
190192
191- expect ( component . cleanForm ) . toHaveBeenCalled ( ) ;
192- } ) ;
193- }
194- ) ;
193+ expect ( component . cleanForm ) . toHaveBeenCalled ( ) ;
194+ } ) ;
195+ } ) ;
195196
196197 it ( 'on cleanFieldsForm the project_id and project_name should be kept' , ( ) => {
197198 const entryFormValueExpected = {
@@ -295,8 +296,8 @@ describe('DetailsFieldsComponent', () => {
295296 uri : '' ,
296297 start_date : '2020-02-05' ,
297298 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' ,
300301 description : '' ,
301302 technology : '' ,
302303 } ) ;
@@ -309,8 +310,8 @@ describe('DetailsFieldsComponent', () => {
309310 activity_id : 'a1' ,
310311 technologies : [ ] ,
311312 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 ( ) ,
314315 uri : '' ,
315316 timezone_offset : new Date ( ) . getTimezoneOffset ( ) ,
316317 } ,
@@ -408,7 +409,7 @@ describe('DetailsFieldsComponent', () => {
408409 activity_id : 'a1' ,
409410 technologies : [ ] ,
410411 description : '' ,
411- start_date : new Date ( '2020-06-11T00:00:10 ' ) . toISOString ( ) ,
412+ start_date : new Date ( '2020-06-11T00:00:00 ' ) . toISOString ( ) ,
412413 uri : 'ticketUri' ,
413414 timezone_offset : new Date ( ) . getTimezoneOffset ( ) ,
414415 } ,
@@ -652,6 +653,58 @@ describe('DetailsFieldsComponent', () => {
652653 componentToTest . onSubmit ( ) ;
653654 expect ( toastrServiceStub . error ) . not . toHaveBeenCalled ( ) ;
654655 } ) ;
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+ } ) ;
655708 /*
656709 TODO As part of https://github.com/ioet/time-tracker-ui/issues/424 a new parameter was added to the details-field-component,
657710 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