|
|
@@ -144,6 +144,39 @@ describe('timeSrv', () => {
|
|
|
expect(timeSrv.time.from).toEqual('now-6h');
|
|
|
expect(timeSrv.time.to).toEqual('now');
|
|
|
});
|
|
|
+
|
|
|
+ describe('data point windowing', () => {
|
|
|
+ it('handles time window specfied as interval string', () => {
|
|
|
+ location = {
|
|
|
+ search: jest.fn(() => ({
|
|
|
+ time: '1410337645000',
|
|
|
+ 'time.window': '10s',
|
|
|
+ })),
|
|
|
+ };
|
|
|
+
|
|
|
+ timeSrv = new TimeSrv(rootScope as any, jest.fn() as any, location as any, timer, new ContextSrvStub() as any);
|
|
|
+
|
|
|
+ timeSrv.init(_dashboard);
|
|
|
+ const time = timeSrv.timeRange();
|
|
|
+ expect(time.from.valueOf()).toEqual(1410337640000);
|
|
|
+ expect(time.to.valueOf()).toEqual(1410337650000);
|
|
|
+ });
|
|
|
+ it('handles time window specified in ms', () => {
|
|
|
+ location = {
|
|
|
+ search: jest.fn(() => ({
|
|
|
+ time: '1410337645000',
|
|
|
+ 'time.window': '10000',
|
|
|
+ })),
|
|
|
+ };
|
|
|
+
|
|
|
+ timeSrv = new TimeSrv(rootScope as any, jest.fn() as any, location as any, timer, new ContextSrvStub() as any);
|
|
|
+
|
|
|
+ timeSrv.init(_dashboard);
|
|
|
+ const time = timeSrv.timeRange();
|
|
|
+ expect(time.from.valueOf()).toEqual(1410337640000);
|
|
|
+ expect(time.to.valueOf()).toEqual(1410337650000);
|
|
|
+ });
|
|
|
+ });
|
|
|
});
|
|
|
|
|
|
describe('setTime', () => {
|