Remove dependency jest-mock-console (#52872)

* Update dependency jest-mock-console to v2

* let's remove jest-mock-console

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Ashley Harrison <ashley.harrison@grafana.com>
This commit is contained in:
renovate[bot]
2022-08-22 15:47:45 +01:00
committed by GitHub
parent 1da4aa25a8
commit 013dda7bb8
4 changed files with 5 additions and 25 deletions

View File

@@ -1,4 +1,3 @@
import mockConsole, { RestoreConsole } from 'jest-mock-console';
import { mapValues } from 'lodash';
import { Observable, Subject, Subscription, Unsubscribable } from 'rxjs';
@@ -123,14 +122,12 @@ const dummyErrorMessage = 'dummy-error';
describe('LiveDataStream', () => {
jest.useFakeTimers();
let restoreConsole: RestoreConsole | undefined;
beforeEach(() => {
restoreConsole = mockConsole();
jest.spyOn(console, 'log').mockImplementation(jest.fn);
});
afterEach(() => {
restoreConsole?.();
jest.clearAllMocks();
});
const expectValueCollectionState = <T>(

View File

@@ -1,4 +1,3 @@
import mockConsole, { RestoreConsole } from 'jest-mock-console';
import { Subject } from 'rxjs';
import { DataQueryResponse, FieldType, LiveChannelScope } from '@grafana/data';
@@ -9,8 +8,6 @@ import { StreamingResponseDataType } from './data/utils';
import { GrafanaLiveService } from './live';
describe('GrafanaLiveService', () => {
let restoreConsole: RestoreConsole | undefined;
const deps = {
backendSrv: {},
centrifugeSrv: {
@@ -28,13 +25,8 @@ describe('GrafanaLiveService', () => {
},
};
beforeEach(() => {
jest.clearAllMocks();
restoreConsole = mockConsole();
});
afterEach(() => {
restoreConsole?.();
jest.clearAllMocks();
});
it('should map response from Centrifuge Service to a streaming data frame', async () => {
@@ -129,6 +121,7 @@ describe('GrafanaLiveService', () => {
});
it('should return an empty frame if first message was not a full frame', async () => {
jest.spyOn(console, 'warn').mockImplementation(jest.fn);
const dummySubject = new Subject<StreamingDataQueryResponse>();
deps.centrifugeSrv.getDataStream.mockReturnValueOnce(dummySubject);
@@ -154,5 +147,6 @@ describe('GrafanaLiveService', () => {
const frame: StreamingDataFrame = response?.data[0];
expect(frame).toBeInstanceOf(StreamingDataFrame);
expect(frame.fields).toEqual([]);
expect(console.warn).toHaveBeenCalled();
});
});