Skip to content

Commit 462690c

Browse files
AkshatAkshat
authored andcommitted
Converted from Jest to Vitest
1 parent 139e985 commit 462690c

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

src/screens/OrgContribution/OrgContribution.test.tsx renamed to src/screens/OrgContribution/OrgContribution.spec.tsx

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import React, { act } from 'react';
1+
import React from 'react';
22
import { MockedProvider } from '@apollo/react-testing';
33
import { render } from '@testing-library/react';
44
import { Provider } from 'react-redux';
55
import { BrowserRouter } from 'react-router-dom';
6-
import 'jest-location-mock';
6+
import { vi, describe, test, expect } from 'vitest';
77
import { I18nextProvider } from 'react-i18next';
88

99
import OrgContribution from './OrgContribution';
@@ -12,15 +12,19 @@ import i18nForTest from 'utils/i18nForTest';
1212
import { StaticMockLink } from 'utils/StaticMockLink';
1313
const link = new StaticMockLink([], true);
1414
async function wait(ms = 100): Promise<void> {
15-
await act(() => {
16-
return new Promise((resolve) => {
17-
setTimeout(resolve, ms);
18-
});
15+
await new Promise((resolve) => {
16+
setTimeout(resolve, ms);
1917
});
2018
}
2119

2220
describe('Organisation Contribution Page', () => {
2321
test('should render props and text elements test for the screen', async () => {
22+
Object.defineProperty(window, 'location', {
23+
value: {
24+
assign: vi.fn(),
25+
},
26+
writable: true,
27+
});
2428
window.location.assign('/orglist');
2529

2630
const { container } = render(
@@ -37,11 +41,10 @@ describe('Organisation Contribution Page', () => {
3741

3842
expect(container.textContent).not.toBe('Loading data...');
3943
await wait();
40-
4144
expect(container.textContent).toMatch('Filter by Name');
4245
expect(container.textContent).toMatch('Filter by Trans. ID');
4346
expect(container.textContent).toMatch('Recent Stats');
4447
expect(container.textContent).toMatch('Contribution');
45-
expect(window.location).toBeAt('/orglist');
48+
expect(window.location.assign).toHaveBeenCalledWith('/orglist');
4649
});
4750
});

0 commit comments

Comments
 (0)