Commit 74bf8096 by Tobias Skarhed

Add mock to test files

parent 962340bc
import '../datasource';
//import { describe, beforeEach, it, expect, angularMocks } from 'test/lib/common';
import { TemplateSrvStub, jestTimeSrvStub } from 'test/specs/helpers';
import { TemplateSrvStub } from 'test/specs/helpers';
import CloudWatchDatasource from '../datasource';
import 'app/features/dashboard/time_srv';
import * as dateMath from 'app/core/utils/datemath';
describe('CloudWatchDatasource', function() {
let instanceSettings = {
jsonData: { defaultRegion: 'us-east-1', access: 'proxy' },
};
let templateSrv = new TemplateSrvStub();
let timeSrv = new jestTimeSrvStub();
let timeSrv = {
time: { from: 'now-1h', to: 'now' },
timeRange: jest.fn(() => {
return {
from: dateMath.parse(timeSrv.time.from, false),
to: dateMath.parse(timeSrv.time.to, true),
};
}),
};
let backendSrv = {};
let ctx = <any>{
backendSrv,
......
//import { describe, beforeEach, it, expect, angularMocks } from 'test/lib/common';
import moment from 'moment';
import { TemplateSrvStub } from 'test/specs/helpers';
import { MysqlDatasource } from '../datasource';
import { CustomVariable } from 'app/features/templating/custom_variable';
describe('MySQLDatasource', function() {
let instanceSettings = { name: 'mysql' };
let backendSrv = {};
let templateSrv = new TemplateSrvStub();
let templateSrv = {
replace: jest.fn(text => text),
};
let ctx = <any>{
backendSrv,
};
......
import moment from 'moment';
import { PostgresDatasource } from '../datasource';
import { CustomVariable } from 'app/features/templating/custom_variable';
import { TemplateSrvStub } from 'test/specs/helpers';
describe('PostgreSQLDatasource', function() {
let instanceSettings = { name: 'postgresql' };
let backendSrv = {};
let templateSrv = new TemplateSrvStub();
let templateSrv = {
replace: jest.fn(text => text),
};
let ctx = <any>{
backendSrv,
};
......
......@@ -195,24 +195,6 @@ export function TemplateSrvStub() {
};
}
export function jestTimeSrvStub() {
this.init = jest.fn();
this.time = { from: 'now-1h', to: 'now' };
this.timeRange = jest.fn(parse => {
if (parse === false) {
return this.time;
}
return {
from: dateMath.parse(this.time.from, false),
to: dateMath.parse(this.time.to, true),
};
});
this.replace = jest.fn(target => target);
this.setTime = jest.fn(time => {
this.time = time;
});
}
var allDeps = {
ContextSrvStub,
TemplateSrvStub,
......
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