mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Add whatwg-fetch and fixes to Playlist tests that break when polyfill is added
This commit is contained in:
parent
2ab13071fb
commit
6557f5a00e
@ -1,3 +1,4 @@
|
|||||||
|
import 'whatwg-fetch';
|
||||||
import { fireEvent, render, screen, waitFor } from '@testing-library/react';
|
import { fireEvent, render, screen, waitFor } from '@testing-library/react';
|
||||||
import userEvent from '@testing-library/user-event';
|
import userEvent from '@testing-library/user-event';
|
||||||
import { History, Location } from 'history';
|
import { History, Location } from 'history';
|
||||||
@ -32,7 +33,7 @@ async function getTestContext({ name, interval, items, uid }: Partial<Playlist>
|
|||||||
const location = {} as Location;
|
const location = {} as Location;
|
||||||
const history = {} as History;
|
const history = {} as History;
|
||||||
const getMock = jest.spyOn(backendSrv, 'get');
|
const getMock = jest.spyOn(backendSrv, 'get');
|
||||||
const putMock = jest.spyOn(backendSrv, 'put');
|
const putMock = jest.spyOn(backendSrv, 'put').mockImplementation(() => Promise.resolve());
|
||||||
|
|
||||||
getMock.mockResolvedValue({
|
getMock.mockResolvedValue({
|
||||||
name: 'Test Playlist',
|
name: 'Test Playlist',
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import 'whatwg-fetch';
|
||||||
import { fireEvent, render, screen, waitFor } from '@testing-library/react';
|
import { fireEvent, render, screen, waitFor } from '@testing-library/react';
|
||||||
import userEvent from '@testing-library/user-event';
|
import userEvent from '@testing-library/user-event';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
@ -25,7 +26,8 @@ jest.mock('app/core/components/TagFilter/TagFilter', () => ({
|
|||||||
function getTestContext({ name, interval, items }: Partial<Playlist> = {}) {
|
function getTestContext({ name, interval, items }: Partial<Playlist> = {}) {
|
||||||
jest.clearAllMocks();
|
jest.clearAllMocks();
|
||||||
const playlist = { name, items, interval } as unknown as Playlist;
|
const playlist = { name, items, interval } as unknown as Playlist;
|
||||||
const backendSrvMock = jest.spyOn(backendSrv, 'post');
|
const backendSrvMock = jest.spyOn(backendSrv, 'post').mockImplementation(() => Promise.resolve());
|
||||||
|
jest.spyOn(backendSrv, 'search').mockResolvedValue([]);
|
||||||
|
|
||||||
const { rerender } = render(
|
const { rerender } = render(
|
||||||
<TestProvider>
|
<TestProvider>
|
||||||
|
Loading…
Reference in New Issue
Block a user