mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Chore: Removes console outputs from runRequest.test.ts (#45375)
This commit is contained in:
@@ -3,10 +3,10 @@ import {
|
|||||||
DataQueryRequest,
|
DataQueryRequest,
|
||||||
DataQueryResponse,
|
DataQueryResponse,
|
||||||
DataSourceApi,
|
DataSourceApi,
|
||||||
|
DataTopic,
|
||||||
dateTime,
|
dateTime,
|
||||||
LoadingState,
|
LoadingState,
|
||||||
PanelData,
|
PanelData,
|
||||||
DataTopic,
|
|
||||||
} from '@grafana/data';
|
} from '@grafana/data';
|
||||||
import { Observable, Subscriber, Subscription } from 'rxjs';
|
import { Observable, Subscriber, Subscription } from 'rxjs';
|
||||||
import { runRequest } from './runRequest';
|
import { runRequest } from './runRequest';
|
||||||
@@ -109,6 +109,26 @@ function runRequestScenario(desc: string, fn: (ctx: ScenarioCtx) => void) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function runRequestScenarioThatThrows(desc: string, fn: (ctx: ScenarioCtx) => void) {
|
||||||
|
describe(desc, () => {
|
||||||
|
const ctx = new ScenarioCtx();
|
||||||
|
let consoleSpy: jest.SpyInstance<any>;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
consoleSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
|
||||||
|
setEchoSrv(new Echo());
|
||||||
|
ctx.reset();
|
||||||
|
return ctx.setupFn();
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
consoleSpy.mockRestore();
|
||||||
|
});
|
||||||
|
|
||||||
|
fn(ctx);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
describe('runRequest', () => {
|
describe('runRequest', () => {
|
||||||
runRequestScenario('with no queries', (ctx) => {
|
runRequestScenario('with no queries', (ctx) => {
|
||||||
ctx.setup(() => {
|
ctx.setup(() => {
|
||||||
@@ -197,7 +217,7 @@ describe('runRequest', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
runRequestScenario('on thrown error', (ctx) => {
|
runRequestScenarioThatThrows('on thrown error', (ctx) => {
|
||||||
ctx.setup(() => {
|
ctx.setup(() => {
|
||||||
ctx.error = new Error('Ohh no');
|
ctx.error = new Error('Ohh no');
|
||||||
ctx.start();
|
ctx.start();
|
||||||
|
|||||||
Reference in New Issue
Block a user