mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
TimeSrv: Refactor service to have no dependency on angular (#32562)
* TimeSrv: Refactor service to have no dependency on angular * Fixing reference to function that does not exist * fixing tests * Worked around the strange error
This commit is contained in:
@@ -24,7 +24,7 @@ import {
|
||||
VariableSuggestion,
|
||||
VariableSuggestionsScope,
|
||||
} from '@grafana/data';
|
||||
import { getAllVariableValuesForUrl } from '../../variables/getAllVariableValuesForUrl';
|
||||
import { getVariablesUrlParams } from '../../variables/getAllVariableValuesForUrl';
|
||||
|
||||
const timeRangeVars = [
|
||||
{
|
||||
@@ -280,7 +280,7 @@ export class LinkSrv implements LinkService {
|
||||
if (link.includeVars) {
|
||||
params = {
|
||||
...params,
|
||||
...getAllVariableValuesForUrl(),
|
||||
...getVariablesUrlParams(),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -19,19 +19,13 @@ describe('linkSrv', () => {
|
||||
let templateSrv: TemplateSrv;
|
||||
|
||||
function initLinkSrv() {
|
||||
const timer = {
|
||||
register: jest.fn(),
|
||||
cancel: jest.fn(),
|
||||
cancelAll: jest.fn(),
|
||||
};
|
||||
|
||||
const _dashboard: any = {
|
||||
time: { from: 'now-6h', to: 'now' },
|
||||
getTimezone: jest.fn(() => 'browser'),
|
||||
timeRangeUpdated: () => {},
|
||||
};
|
||||
|
||||
const timeSrv = new TimeSrv(jest.fn() as any, timer, {} as any);
|
||||
const timeSrv = new TimeSrv({} as any);
|
||||
timeSrv.init(_dashboard);
|
||||
timeSrv.setTime({ from: 'now-1h', to: 'now' });
|
||||
_dashboard.refresh = false;
|
||||
@@ -126,10 +120,8 @@ describe('linkSrv', () => {
|
||||
({ url, appSubUrl, expected }) => {
|
||||
locationUtil.initialize({
|
||||
config: { appSubUrl } as any,
|
||||
// @ts-ignore
|
||||
buildParamsFromVariables: () => {},
|
||||
// @ts-ignore
|
||||
getTimeRangeForUrl: () => {},
|
||||
getVariablesUrlParams: (() => {}) as any,
|
||||
getTimeRangeForUrl: (() => {}) as any,
|
||||
});
|
||||
|
||||
const link = linkSrv.getDataLinkUIModel(
|
||||
|
||||
Reference in New Issue
Block a user