From e93aa07c25fb4296b40cb186274d3ee0d5dd8f16 Mon Sep 17 00:00:00 2001 From: Dominik Prokop Date: Tue, 17 Dec 2019 12:35:23 +0100 Subject: [PATCH] Enable config mocking --- public/app/core/config.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/public/app/core/config.ts b/public/app/core/config.ts index ff5b31a005f..92684327a39 100644 --- a/public/app/core/config.ts +++ b/public/app/core/config.ts @@ -1,5 +1,18 @@ import { config, GrafanaBootConfig } from '@grafana/runtime'; - // Legacy binding paths export { config, GrafanaBootConfig as Settings }; + +let configMock: Partial | null = null; + export default config; + +export const getConfig = () => { + return configMock || config; +}; + +export const mockConfig = (mock: Partial) => { + configMock = mock as GrafanaBootConfig; + return () => { + configMock = null; + }; +};