@@ -2,6 +2,7 @@ import {inject, TestBed} from '@angular/core/testing';
22import { UtilsService } from './utils.service' ;
33import * as momentNs from 'moment' ;
44import { IDate } from '../../models/date.model' ;
5+
56const moment = momentNs ;
67
78describe ( 'Service: ObUtilsService' , ( ) => {
@@ -116,4 +117,16 @@ describe('Service: ObUtilsService', () => {
116117 expect ( service . datesStringToStringArray ( '14,01-1984| asdasd' ) )
117118 . toEqual ( [ '14,01-1984' , 'asdasd' ] ) ;
118119 } ) ) ;
120+
121+ it ( 'check convertToString' , inject ( [ UtilsService ] , ( service : UtilsService ) => {
122+ const format = 'MM/DD/YYYY' ;
123+ expect ( service . convertToString ( null , format ) ) . toEqual ( '' ) ;
124+ expect ( service . convertToString ( '' , format ) ) . toEqual ( '' ) ;
125+ expect ( service . convertToString ( moment ( ) , format ) ) . toEqual ( moment ( ) . format ( format ) ) ;
126+ expect ( service . convertToString ( [ moment ( ) ] , format ) ) . toEqual ( moment ( ) . format ( format ) ) ;
127+ expect ( service . convertToString ( [ moment ( ) , moment ( ) . add ( 1 , 'd' ) ] , format ) )
128+ . toEqual ( moment ( ) . format ( format ) + ' | ' + moment ( ) . add ( 1 , 'd' ) . format ( format ) ) ;
129+ expect ( service . convertToString ( [ moment ( ) . format ( format ) , moment ( ) . add ( 1 , 'd' ) . format ( format ) ] , format ) )
130+ . toEqual ( moment ( ) . format ( format ) + ' | ' + moment ( ) . add ( 1 , 'd' ) . format ( format ) ) ;
131+ } ) ) ;
119132} ) ;
0 commit comments