From 12d158f391d0256802ff5be4bb0fb1f9335f4b66 Mon Sep 17 00:00:00 2001 From: Tobias Skarhed Date: Wed, 4 Jul 2018 10:43:36 +0200 Subject: [PATCH] Add mocks in test file --- .../elasticsearch/specs/datasource.jest.ts | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/public/app/plugins/datasource/elasticsearch/specs/datasource.jest.ts b/public/app/plugins/datasource/elasticsearch/specs/datasource.jest.ts index b6d19d003da..e9f7a61a572 100644 --- a/public/app/plugins/datasource/elasticsearch/specs/datasource.jest.ts +++ b/public/app/plugins/datasource/elasticsearch/specs/datasource.jest.ts @@ -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 = { $rootScope,