Commit 12d158f3 by Tobias Skarhed

Add mocks in test file

parent 8f1bcd91
......@@ -2,7 +2,8 @@ import _ from 'lodash';
import moment from 'moment';
import angular from 'angular';
import { ElasticDatasource } from '../datasource';
import { jestTimeSrvStub, TemplateSrvStub } from 'test/specs/helpers';
import * as dateMath from 'app/core/utils/datemath';
describe('ElasticDatasource', function() {
let backendSrv = {
......@@ -14,9 +15,23 @@ describe('ElasticDatasource', function() {
appEvent: jest.fn(),
};
let templateSrv = new TemplateSrvStub();
let templateSrv = {
replace: jest.fn(text => text),
getAdhocFilters: jest.fn(() => []),
};
let timeSrv = new jestTimeSrvStub();
let timeSrv = {
time: { from: 'now-1h', to: 'now' },
timeRange: jest.fn(parse => {
return {
from: dateMath.parse(this.time.from, false),
to: dateMath.parse(this.time.to, true),
};
}),
setTime: jest.fn(time => {
this.time = time;
}),
};
let ctx = <any>{
$rootScope,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment