mirror of
https://github.com/grafana/grafana.git
synced 2025-08-26 17:50:43 +08:00
Create new instance in beforeEach
This commit is contained in:
@ -5,15 +5,17 @@ import { MysqlDatasource } from '../datasource';
|
|||||||
import { CustomVariable } from 'app/features/templating/custom_variable';
|
import { CustomVariable } from 'app/features/templating/custom_variable';
|
||||||
|
|
||||||
describe('MySQLDatasource', function() {
|
describe('MySQLDatasource', function() {
|
||||||
|
|
||||||
let instanceSettings = { name: 'mysql' };
|
let instanceSettings = { name: 'mysql' };
|
||||||
let backendSrv = {};
|
let backendSrv = {};
|
||||||
let templateSrv = new TemplateSrvStub();
|
let templateSrv = new TemplateSrvStub();
|
||||||
let ctx = <any>{
|
let ctx = <any>{
|
||||||
ds: new MysqlDatasource(instanceSettings, backendSrv, {}, templateSrv),
|
backendSrv,
|
||||||
backendSrv
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
ctx.ds = new MysqlDatasource(instanceSettings, backendSrv, {}, templateSrv);
|
||||||
|
});
|
||||||
|
|
||||||
describe('When performing annotationQuery', function() {
|
describe('When performing annotationQuery', function() {
|
||||||
let results;
|
let results;
|
||||||
|
|
||||||
@ -49,7 +51,7 @@ describe('MySQLDatasource', function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
ctx.backendSrv.datasourceRequest = jest.fn((options) => {
|
ctx.backendSrv.datasourceRequest = jest.fn(options => {
|
||||||
return Promise.resolve({ data: response, status: 200 });
|
return Promise.resolve({ data: response, status: 200 });
|
||||||
});
|
});
|
||||||
ctx.ds.annotationQuery(options).then(function(data) {
|
ctx.ds.annotationQuery(options).then(function(data) {
|
||||||
@ -92,7 +94,7 @@ describe('MySQLDatasource', function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
ctx.backendSrv.datasourceRequest = jest.fn((options) => {
|
ctx.backendSrv.datasourceRequest = jest.fn(options => {
|
||||||
return Promise.resolve({ data: response, status: 200 });
|
return Promise.resolve({ data: response, status: 200 });
|
||||||
});
|
});
|
||||||
ctx.ds.metricFindQuery(query).then(function(data) {
|
ctx.ds.metricFindQuery(query).then(function(data) {
|
||||||
@ -128,7 +130,7 @@ describe('MySQLDatasource', function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
ctx.backendSrv.datasourceRequest = jest.fn((options) => {
|
ctx.backendSrv.datasourceRequest = jest.fn(options => {
|
||||||
return Promise.resolve({ data: response, status: 200 });
|
return Promise.resolve({ data: response, status: 200 });
|
||||||
});
|
});
|
||||||
ctx.ds.metricFindQuery(query).then(function(data) {
|
ctx.ds.metricFindQuery(query).then(function(data) {
|
||||||
@ -166,7 +168,7 @@ describe('MySQLDatasource', function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
ctx.backendSrv.datasourceRequest = jest.fn((options) => {
|
ctx.backendSrv.datasourceRequest = jest.fn(options => {
|
||||||
return Promise.resolve({ data: response, status: 200 });
|
return Promise.resolve({ data: response, status: 200 });
|
||||||
});
|
});
|
||||||
ctx.ds.metricFindQuery(query).then(function(data) {
|
ctx.ds.metricFindQuery(query).then(function(data) {
|
||||||
|
@ -9,10 +9,13 @@ describe('PostgreSQLDatasource', function() {
|
|||||||
let backendSrv = {};
|
let backendSrv = {};
|
||||||
let templateSrv = new TemplateSrvStub();
|
let templateSrv = new TemplateSrvStub();
|
||||||
let ctx = <any>{
|
let ctx = <any>{
|
||||||
ds: new PostgresDatasource(instanceSettings, backendSrv, {}, templateSrv),
|
backendSrv,
|
||||||
backendSrv
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
ctx.ds = new PostgresDatasource(instanceSettings, backendSrv, {}, templateSrv);
|
||||||
|
});
|
||||||
|
|
||||||
describe('When performing annotationQuery', function() {
|
describe('When performing annotationQuery', function() {
|
||||||
let results;
|
let results;
|
||||||
|
|
||||||
@ -48,7 +51,7 @@ describe('PostgreSQLDatasource', function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
ctx.backendSrv.datasourceRequest = jest.fn((options) => {
|
ctx.backendSrv.datasourceRequest = jest.fn(options => {
|
||||||
return Promise.resolve({ data: response, status: 200 });
|
return Promise.resolve({ data: response, status: 200 });
|
||||||
});
|
});
|
||||||
ctx.ds.annotationQuery(options).then(function(data) {
|
ctx.ds.annotationQuery(options).then(function(data) {
|
||||||
@ -91,7 +94,7 @@ describe('PostgreSQLDatasource', function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
ctx.backendSrv.datasourceRequest = jest.fn((options) => {
|
ctx.backendSrv.datasourceRequest = jest.fn(options => {
|
||||||
return Promise.resolve({ data: response, status: 200 });
|
return Promise.resolve({ data: response, status: 200 });
|
||||||
});
|
});
|
||||||
ctx.ds.metricFindQuery(query).then(function(data) {
|
ctx.ds.metricFindQuery(query).then(function(data) {
|
||||||
@ -127,7 +130,7 @@ describe('PostgreSQLDatasource', function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
ctx.backendSrv.datasourceRequest = jest.fn((options) => {
|
ctx.backendSrv.datasourceRequest = jest.fn(options => {
|
||||||
return Promise.resolve({ data: response, status: 200 });
|
return Promise.resolve({ data: response, status: 200 });
|
||||||
});
|
});
|
||||||
ctx.ds.metricFindQuery(query).then(function(data) {
|
ctx.ds.metricFindQuery(query).then(function(data) {
|
||||||
@ -165,7 +168,7 @@ describe('PostgreSQLDatasource', function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
ctx.backendSrv.datasourceRequest = jest.fn((options) => {
|
ctx.backendSrv.datasourceRequest = jest.fn(options => {
|
||||||
return Promise.resolve({ data: response, status: 200 });
|
return Promise.resolve({ data: response, status: 200 });
|
||||||
});
|
});
|
||||||
ctx.ds.metricFindQuery(query).then(function(data) {
|
ctx.ds.metricFindQuery(query).then(function(data) {
|
||||||
|
Reference in New Issue
Block a user