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