mirror of
https://github.com/grafana/grafana.git
synced 2026-09-05 04:40:13 -05:00
Chore: fix type errors in tests (#63270)
* fix any's in tests * fix more any's in tests * more test type fixes * fixing any's in tests part 3 * more test type fixes * fixing test any's p5 * some tidy up * fix template_srv
This commit is contained in:
@@ -1,21 +1,23 @@
|
||||
import { Subject } from 'rxjs';
|
||||
|
||||
import { DataQueryResponse, FieldType, LiveChannelScope } from '@grafana/data';
|
||||
import { BackendSrv } from '@grafana/runtime';
|
||||
|
||||
import { StreamingDataQueryResponse } from './centrifuge/service';
|
||||
import { CentrifugeSrv, StreamingDataQueryResponse } from './centrifuge/service';
|
||||
import { StreamingDataFrame } from './data/StreamingDataFrame';
|
||||
import { StreamingResponseDataType } from './data/utils';
|
||||
import { GrafanaLiveService } from './live';
|
||||
|
||||
describe('GrafanaLiveService', () => {
|
||||
const mockGetDataStream = jest.fn();
|
||||
const deps = {
|
||||
backendSrv: {},
|
||||
backendSrv: {} as BackendSrv,
|
||||
centrifugeSrv: {
|
||||
getDataStream: jest.fn(),
|
||||
},
|
||||
getDataStream: mockGetDataStream,
|
||||
} as unknown as CentrifugeSrv,
|
||||
};
|
||||
|
||||
const liveService = new GrafanaLiveService(deps as any);
|
||||
const liveService = new GrafanaLiveService(deps);
|
||||
|
||||
const liveDataStreamOptions = {
|
||||
addr: {
|
||||
@@ -31,7 +33,7 @@ describe('GrafanaLiveService', () => {
|
||||
|
||||
it('should map response from Centrifuge Service to a streaming data frame', async () => {
|
||||
const dummySubject = new Subject<StreamingDataQueryResponse>();
|
||||
deps.centrifugeSrv.getDataStream.mockReturnValueOnce(dummySubject);
|
||||
mockGetDataStream.mockReturnValueOnce(dummySubject);
|
||||
|
||||
let response: DataQueryResponse | undefined;
|
||||
liveService.getDataStream(liveDataStreamOptions).subscribe((next) => {
|
||||
@@ -53,7 +55,7 @@ describe('GrafanaLiveService', () => {
|
||||
|
||||
it('should add partial streaming data to the buffer', async () => {
|
||||
const dummySubject = new Subject<StreamingDataQueryResponse>();
|
||||
deps.centrifugeSrv.getDataStream.mockReturnValueOnce(dummySubject);
|
||||
mockGetDataStream.mockReturnValueOnce(dummySubject);
|
||||
|
||||
let response: DataQueryResponse | undefined;
|
||||
liveService.getDataStream(liveDataStreamOptions).subscribe((next) => {
|
||||
@@ -123,7 +125,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);
|
||||
mockGetDataStream.mockReturnValueOnce(dummySubject);
|
||||
|
||||
let response: DataQueryResponse | undefined;
|
||||
liveService.getDataStream(liveDataStreamOptions).subscribe((next) => {
|
||||
|
||||
Reference in New Issue
Block a user