rtl 13 fixes for tests with type issues
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
import { Entity } from '@backstage/catalog-model';
|
||||
import { EntityProvider } from '@backstage/plugin-catalog-react';
|
||||
import { renderHook } from '@testing-library/react';
|
||||
import { act, renderHook } from '@testing-library/react';
|
||||
import React, { PropsWithChildren } from 'react';
|
||||
import { WebsiteListResponse } from '@backstage/plugin-lighthouse-common';
|
||||
import { lighthouseApiRef } from '../api';
|
||||
@@ -77,8 +77,8 @@ describe('useWebsiteForEntity', () => {
|
||||
});
|
||||
|
||||
it('returns the lighthouse information for the website url in annotations', async () => {
|
||||
const { result, waitForNextUpdate } = subject();
|
||||
await waitForNextUpdate();
|
||||
const { result } = subject();
|
||||
await act(async () => {});
|
||||
expect(result.current?.value).toBe(website);
|
||||
});
|
||||
|
||||
@@ -92,8 +92,8 @@ describe('useWebsiteForEntity', () => {
|
||||
});
|
||||
|
||||
it('posts the error to the error api and returns the error to the caller', async () => {
|
||||
const { result, waitForNextUpdate } = subject();
|
||||
await waitForNextUpdate();
|
||||
const { result } = subject();
|
||||
await act(async () => {});
|
||||
expect(result.current?.error).toBe(error);
|
||||
expect(mockErrorApi.post).toHaveBeenCalledWith(error);
|
||||
});
|
||||
@@ -109,8 +109,8 @@ describe('useWebsiteForEntity', () => {
|
||||
});
|
||||
|
||||
it('does not post the error to the error api and returns the error to the caller', async () => {
|
||||
const { result, waitForNextUpdate } = subject();
|
||||
await waitForNextUpdate();
|
||||
const { result } = subject();
|
||||
await act(async () => {});
|
||||
expect(result.current?.error).toBe(error);
|
||||
expect(mockErrorApi.post).not.toHaveBeenCalledWith(error);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user