|
|
|
@ -4,7 +4,7 @@ import { BackendSrv } from 'app/core/services/backend_srv'; |
|
|
|
|
jest.mock('../datasource'); |
|
|
|
|
jest.mock('app/core/services/backend_srv'); |
|
|
|
|
|
|
|
|
|
describe('Prometheus editor completer', function () { |
|
|
|
|
describe('Prometheus editor completer', function() { |
|
|
|
|
function getSessionStub(data) { |
|
|
|
|
return { |
|
|
|
|
getTokenAt: jest.fn(() => data.currentToken), |
|
|
|
@ -19,8 +19,11 @@ describe('Prometheus editor completer', function () { |
|
|
|
|
const datasourceStub = new PrometheusDatasource({}, {}, backendSrv, {}, {}); |
|
|
|
|
|
|
|
|
|
datasourceStub.metadataRequest = jest.fn(() => |
|
|
|
|
Promise.resolve({ data: { data: [{ metric: { job: 'node', instance: 'localhost:9100', }, },], }, })); |
|
|
|
|
datasourceStub.getTimeRange = jest.fn(() => { return { from: 1514732400, to: 1514818800 }; }); |
|
|
|
|
Promise.resolve({ data: { data: [{ metric: { job: 'node', instance: 'localhost:9100' } }] } }) |
|
|
|
|
); |
|
|
|
|
datasourceStub.getTimeRange = jest.fn(() => { |
|
|
|
|
return { start: 1514732400, end: 1514818800 }; |
|
|
|
|
}); |
|
|
|
|
datasourceStub.performSuggestQuery = jest.fn(() => Promise.resolve(['node_cpu'])); |
|
|
|
|
|
|
|
|
|
const templateSrv = { |
|
|
|
|