Commit 962340bc by Tobias Skarhed

Create new instance in beforeEach

parent a37a0c7b
......@@ -5,15 +5,17 @@ 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 ctx = <any>{
ds: new MysqlDatasource(instanceSettings, backendSrv, {}, templateSrv),
backendSrv
backendSrv,
};
beforeEach(() => {
ctx.ds = new MysqlDatasource(instanceSettings, backendSrv, {}, templateSrv);
});
describe('When performing annotationQuery', function() {
let results;
......@@ -49,7 +51,7 @@ describe('MySQLDatasource', function() {
};
beforeEach(function() {
ctx.backendSrv.datasourceRequest = jest.fn((options) => {
ctx.backendSrv.datasourceRequest = jest.fn(options => {
return Promise.resolve({ data: response, status: 200 });
});
ctx.ds.annotationQuery(options).then(function(data) {
......@@ -92,7 +94,7 @@ describe('MySQLDatasource', function() {
};
beforeEach(function() {
ctx.backendSrv.datasourceRequest = jest.fn((options) => {
ctx.backendSrv.datasourceRequest = jest.fn(options => {
return Promise.resolve({ data: response, status: 200 });
});
ctx.ds.metricFindQuery(query).then(function(data) {
......@@ -128,7 +130,7 @@ describe('MySQLDatasource', function() {
};
beforeEach(function() {
ctx.backendSrv.datasourceRequest = jest.fn((options) => {
ctx.backendSrv.datasourceRequest = jest.fn(options => {
return Promise.resolve({ data: response, status: 200 });
});
ctx.ds.metricFindQuery(query).then(function(data) {
......@@ -166,7 +168,7 @@ describe('MySQLDatasource', function() {
};
beforeEach(function() {
ctx.backendSrv.datasourceRequest = jest.fn((options) => {
ctx.backendSrv.datasourceRequest = jest.fn(options => {
return Promise.resolve({ data: response, status: 200 });
});
ctx.ds.metricFindQuery(query).then(function(data) {
......
......@@ -9,10 +9,13 @@ describe('PostgreSQLDatasource', function() {
let backendSrv = {};
let templateSrv = new TemplateSrvStub();
let ctx = <any>{
ds: new PostgresDatasource(instanceSettings, backendSrv, {}, templateSrv),
backendSrv
backendSrv,
};
beforeEach(() => {
ctx.ds = new PostgresDatasource(instanceSettings, backendSrv, {}, templateSrv);
});
describe('When performing annotationQuery', function() {
let results;
......@@ -48,7 +51,7 @@ describe('PostgreSQLDatasource', function() {
};
beforeEach(function() {
ctx.backendSrv.datasourceRequest = jest.fn((options) => {
ctx.backendSrv.datasourceRequest = jest.fn(options => {
return Promise.resolve({ data: response, status: 200 });
});
ctx.ds.annotationQuery(options).then(function(data) {
......@@ -91,7 +94,7 @@ describe('PostgreSQLDatasource', function() {
};
beforeEach(function() {
ctx.backendSrv.datasourceRequest = jest.fn((options) => {
ctx.backendSrv.datasourceRequest = jest.fn(options => {
return Promise.resolve({ data: response, status: 200 });
});
ctx.ds.metricFindQuery(query).then(function(data) {
......@@ -127,7 +130,7 @@ describe('PostgreSQLDatasource', function() {
};
beforeEach(function() {
ctx.backendSrv.datasourceRequest = jest.fn((options) => {
ctx.backendSrv.datasourceRequest = jest.fn(options => {
return Promise.resolve({ data: response, status: 200 });
});
ctx.ds.metricFindQuery(query).then(function(data) {
......@@ -165,7 +168,7 @@ describe('PostgreSQLDatasource', function() {
};
beforeEach(() => {
ctx.backendSrv.datasourceRequest = jest.fn((options) => {
ctx.backendSrv.datasourceRequest = jest.fn(options => {
return Promise.resolve({ data: response, status: 200 });
});
ctx.ds.metricFindQuery(query).then(function(data) {
......
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