From 820a70f49a53708abbca75a0e17646f327e0ac00 Mon Sep 17 00:00:00 2001 From: Ashley Harrison Date: Fri, 11 Feb 2022 16:34:06 +0000 Subject: [PATCH] Stub deprecation warning in kbn unit tests (#45313) --- public/app/core/utils/kbn.test.ts | 7 +++++++ public/app/core/utils/kbn.ts | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/public/app/core/utils/kbn.test.ts b/public/app/core/utils/kbn.test.ts index d6187c90995..1ebae32ecc1 100644 --- a/public/app/core/utils/kbn.test.ts +++ b/public/app/core/utils/kbn.test.ts @@ -1,6 +1,13 @@ import kbn from './kbn'; import { DecimalCount, TimeZone } from '@grafana/data'; +// Most of the methods in this file are deprecated +// Stub the deprecation warning here to prevent polluting the test output +jest.mock('@grafana/data', () => ({ + ...jest.requireActual('@grafana/data'), + deprecationWarning: () => {}, +})); + interface ValueFormatTest { id: string; decimals?: DecimalCount; diff --git a/public/app/core/utils/kbn.ts b/public/app/core/utils/kbn.ts index 6b797dbf047..d4ff3e73d72 100644 --- a/public/app/core/utils/kbn.ts +++ b/public/app/core/utils/kbn.ts @@ -50,7 +50,7 @@ const kbn = { addSlashes: (str: string) => str.replace(/[\'\"\\0]/g, '\\$&'), /** @deprecated since 7.2, use grafana/data */ describeInterval: (str: string) => { - deprecationWarning('kbn.ts', 'kbn.stringToJsRegex()', '@grafana/data'); + deprecationWarning('kbn.ts', 'kbn.describeInterval()', '@grafana/data'); return rangeUtil.describeInterval(str); }, /** @deprecated since 7.2, use grafana/data */