mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
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:
@@ -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);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user