import moment from 'moment' ; import { VisTypeTimeseriesVisDataRequest } from '../../../types' ; import { getTimerange } from './get_timerange' ; describe ( 'getTimerange(req)' , ( ) => { test ( 'should return a moment object for to and from' , ( ) => { const req = { body : { timerange : { min : '2017-01-01T00:00:00Z' , max : '2017-01-01T01:00:00Z' , } , } , } as unknown as VisTypeTimeseriesVisDataRequest ; const { from , to } = getTimerange ( req ) ; expect ( moment . isMoment ( from ) ) . toEqual ( true ) ; expect ( moment . isMoment ( to ) ) . toEqual ( true ) ; expect ( moment . utc ( '2017-01-01T00:00:00Z' ) . isSame ( from ) ) . toEqual ( true ) ; expect ( moment . utc ( '2017-01-01T01:00:00Z' ) . isSame ( to ) ) . toEqual ( true ) ; } ) ; } ) ;