diff --git a/src/screens/OrgContribution/OrgContribution.test.tsx b/src/screens/OrgContribution/OrgContribution.spec.tsx similarity index 80% rename from src/screens/OrgContribution/OrgContribution.test.tsx rename to src/screens/OrgContribution/OrgContribution.spec.tsx index f9f63c6807..f12057a626 100644 --- a/src/screens/OrgContribution/OrgContribution.test.tsx +++ b/src/screens/OrgContribution/OrgContribution.spec.tsx @@ -1,9 +1,9 @@ -import React, { act } from 'react'; +import React from 'react'; import { MockedProvider } from '@apollo/react-testing'; import { render } from '@testing-library/react'; import { Provider } from 'react-redux'; import { BrowserRouter } from 'react-router-dom'; -import 'jest-location-mock'; +import { vi, describe, test, expect } from 'vitest'; import { I18nextProvider } from 'react-i18next'; import OrgContribution from './OrgContribution'; @@ -12,15 +12,20 @@ import i18nForTest from 'utils/i18nForTest'; import { StaticMockLink } from 'utils/StaticMockLink'; const link = new StaticMockLink([], true); async function wait(ms = 100): Promise { - await act(() => { - return new Promise((resolve) => { - setTimeout(resolve, ms); - }); + await new Promise((resolve) => { + setTimeout(resolve, ms); }); } describe('Organisation Contribution Page', () => { test('should render props and text elements test for the screen', async () => { + Object.defineProperty(window, 'location', { + value: { + assign: vi.fn(), + }, + writable: true, + }); + window.location.assign('/orglist'); const { container } = render( @@ -37,11 +42,10 @@ describe('Organisation Contribution Page', () => { expect(container.textContent).not.toBe('Loading data...'); await wait(); - expect(container.textContent).toMatch('Filter by Name'); expect(container.textContent).toMatch('Filter by Trans. ID'); expect(container.textContent).toMatch('Recent Stats'); expect(container.textContent).toMatch('Contribution'); - expect(window.location).toBeAt('/orglist'); + expect(window.location.assign).toHaveBeenCalledWith('/orglist'); }); });