Angular cleanup: Don't inject in link_srv (#36849)

* Angular cleanup: Don't inject in link_srv

* link_srv: Fix unit tests

* kick drone
This commit is contained in:
Ashley Harrison
2021-07-19 09:16:36 +01:00
committed by GitHub
parent 37caebc934
commit b8a5f38d2a
4 changed files with 41 additions and 31 deletions

View File

@@ -2,24 +2,25 @@ import React from 'react';
import { DebugSection } from './DebugSection';
import { mount } from 'enzyme';
import { getLinkSrv, LinkService, LinkSrv, setLinkSrv } from '../../../../features/panel/panellinks/link_srv';
import { TimeSrv } from '../../../../features/dashboard/services/TimeSrv';
import { dateTime } from '@grafana/data';
import { TemplateSrv } from '../../../../features/templating/template_srv';
// We do not need more here and TimeSrv is hard to setup fully.
jest.mock('app/features/dashboard/services/TimeSrv', () => ({
getTimeSrv: () => ({
timeRangeForUrl() {
const from = dateTime().subtract(1, 'h');
const to = dateTime();
return { from, to, raw: { from, to } };
},
}),
}));
describe('DebugSection', () => {
let originalLinkSrv: LinkService;
// This needs to be setup so we can test interpolation in the debugger
beforeAll(() => {
// We do not need more here and TimeSrv is hard to setup fully.
const timeSrvMock: TimeSrv = {
timeRangeForUrl() {
const from = dateTime().subtract(1, 'h');
const to = dateTime();
return { from, to, raw: { from, to } };
},
} as any;
const linkService = new LinkSrv(new TemplateSrv(), timeSrvMock);
const linkService = new LinkSrv();
originalLinkSrv = getLinkSrv();
setLinkSrv(linkService);
});