@ -10,12 +10,6 @@ jest.mock('app/core/core', () => ({
} ) ) ;
describe ( 'timeSrv' , ( ) = > {
const timer = {
register : jest.fn ( ) ,
cancel : jest.fn ( ) ,
cancelAll : jest.fn ( ) ,
} ;
let timeSrv : TimeSrv ;
const _dashboard : any = {
@ -25,7 +19,7 @@ describe('timeSrv', () => {
} ;
beforeEach ( ( ) = > {
timeSrv = new TimeSrv ( jest . fn ( ) as any , timer , new ContextSrvStub ( ) as any ) ;
timeSrv = new TimeSrv ( new ContextSrvStub ( ) as any ) ;
timeSrv . init ( _dashboard ) ;
_dashboard . refresh = false ;
} ) ;
@ -50,7 +44,7 @@ describe('timeSrv', () => {
it ( 'should handle relative times' , ( ) = > {
locationService . push ( '/d/id?from=now-2d&to=now' ) ;
timeSrv = new TimeSrv ( jest . fn ( ) as any , timer , new ContextSrvStub ( ) as any ) ;
timeSrv = new TimeSrv ( new ContextSrvStub ( ) as any ) ;
timeSrv . init ( _dashboard ) ;
const time = timeSrv . timeRange ( ) ;
@ -61,7 +55,7 @@ describe('timeSrv', () => {
it ( 'should handle formatted dates' , ( ) = > {
locationService . push ( '/d/id?from=20140410T052010&to=20140520T031022' ) ;
timeSrv = new TimeSrv ( jest . fn ( ) as any , timer , new ContextSrvStub ( ) as any ) ;
timeSrv = new TimeSrv ( new ContextSrvStub ( ) as any ) ;
timeSrv . init ( _dashboard ) ;
const time = timeSrv . timeRange ( ) ;
@ -72,7 +66,7 @@ describe('timeSrv', () => {
it ( 'should ignore refresh if time absolute' , ( ) = > {
locationService . push ( '/d/id?from=20140410T052010&to=20140520T031022' ) ;
timeSrv = new TimeSrv ( jest . fn ( ) as any , timer , new ContextSrvStub ( ) as any ) ;
timeSrv = new TimeSrv ( new ContextSrvStub ( ) as any ) ;
// dashboard saved with refresh on
_dashboard . refresh = true ;
@ -84,7 +78,7 @@ describe('timeSrv', () => {
it ( 'should handle formatted dates without time' , ( ) = > {
locationService . push ( '/d/id?from=20140410&to=20140520' ) ;
timeSrv = new TimeSrv ( jest . fn ( ) as any , timer , new ContextSrvStub ( ) as any ) ;
timeSrv = new TimeSrv ( new ContextSrvStub ( ) as any ) ;
timeSrv . init ( _dashboard ) ;
const time = timeSrv . timeRange ( ) ;
@ -95,7 +89,7 @@ describe('timeSrv', () => {
it ( 'should handle epochs' , ( ) = > {
locationService . push ( '/d/id?from=1410337646373&to=1410337665699' ) ;
timeSrv = new TimeSrv ( jest . fn ( ) as any , timer , new ContextSrvStub ( ) as any ) ;
timeSrv = new TimeSrv ( new ContextSrvStub ( ) as any ) ;
timeSrv . init ( _dashboard ) ;
const time = timeSrv . timeRange ( ) ;
@ -106,7 +100,7 @@ describe('timeSrv', () => {
it ( 'should handle epochs that look like formatted date without time' , ( ) = > {
locationService . push ( '/d/id?from=20149999&to=20159999' ) ;
timeSrv = new TimeSrv ( jest . fn ( ) as any , timer , new ContextSrvStub ( ) as any ) ;
timeSrv = new TimeSrv ( new ContextSrvStub ( ) as any ) ;
timeSrv . init ( _dashboard ) ;
const time = timeSrv . timeRange ( ) ;
@ -117,7 +111,7 @@ describe('timeSrv', () => {
it ( 'should handle epochs that look like formatted date' , ( ) = > {
locationService . push ( '/d/id?from=201499991234567&to=201599991234567' ) ;
timeSrv = new TimeSrv ( jest . fn ( ) as any , timer , new ContextSrvStub ( ) as any ) ;
timeSrv = new TimeSrv ( new ContextSrvStub ( ) as any ) ;
timeSrv . init ( _dashboard ) ;
const time = timeSrv . timeRange ( ) ;
@ -128,7 +122,7 @@ describe('timeSrv', () => {
it ( 'should handle bad dates' , ( ) = > {
locationService . push ( '/d/id?from=20151126T00010%3C%2Fp%3E%3Cspan%20class&to=now' ) ;
timeSrv = new TimeSrv ( jest . fn ( ) as any , timer , new ContextSrvStub ( ) as any ) ;
timeSrv = new TimeSrv ( new ContextSrvStub ( ) as any ) ;
_dashboard . time . from = 'now-6h' ;
timeSrv . init ( _dashboard ) ;
@ -140,7 +134,7 @@ describe('timeSrv', () => {
it ( 'handles time window specfied as interval string' , ( ) = > {
locationService . push ( '/d/id?time=1410337645000&time.window=10s' ) ;
timeSrv = new TimeSrv ( jest . fn ( ) as any , timer , new ContextSrvStub ( ) as any ) ;
timeSrv = new TimeSrv ( new ContextSrvStub ( ) as any ) ;
timeSrv . init ( _dashboard ) ;
const time = timeSrv . timeRange ( ) ;
@ -151,7 +145,7 @@ describe('timeSrv', () => {
it ( 'handles time window specified in ms' , ( ) = > {
locationService . push ( '/d/id?time=1410337645000&time.window=10000' ) ;
timeSrv = new TimeSrv ( jest . fn ( ) as any , timer , new ContextSrvStub ( ) as any ) ;
timeSrv = new TimeSrv ( new ContextSrvStub ( ) as any ) ;
timeSrv . init ( _dashboard ) ;
const time = timeSrv . timeRange ( ) ;