Chore: update datasource test

This commit is contained in:
Matias Chomicki 2022-09-29 15:51:47 +02:00
parent 22e547f625
commit 2cbbc39e18
2 changed files with 19 additions and 1 deletions

View File

@ -889,6 +889,24 @@ describe('applyTemplateVariables', () => {
});
});
describe('getTimeRange*()', () => {
it('exposes the current time range', () => {
const ds = createLokiDatasource();
const timeRange = ds.getTimeRange();
expect(timeRange.from).toBeDefined();
expect(timeRange.to).toBeDefined();
});
it('exposes time range as params', () => {
const ds = createLokiDatasource();
const params = ds.getTimeRangeParams();
// Returns a very big integer, so we stringify it for the assertion
expect(JSON.stringify(params)).toEqual('{"start":1524650400000000000,"end":1524654000000000000}');
});
});
describe('Variable support', () => {
it('has Loki variable support', () => {
const ds = createLokiDatasource(templateSrvStub);

View File

@ -18,7 +18,7 @@ const rawRange = {
};
const defaultTimeSrvMock = {
timeRange: () => ({
timeRange: jest.fn().mockReturnValue({
from: rawRange.from,
to: rawRange.to,
raw: rawRange,