Skip to content

Commit

Permalink
Refactor : src/screens/OrgContribution component from Jest to Vitest (#…
Browse files Browse the repository at this point in the history
…2729)

* Converted from Jest to Vitest

* Converted the code from Jest to Vitest

* Converted from Jest to Vitest

---------

Co-authored-by: Akshat <[email protected]>
  • Loading branch information
Akshat76845 and Akshat authored Dec 22, 2024
1 parent 9108753 commit 705dcbc
Showing 1 changed file with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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<void> {
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(
Expand All @@ -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');
});
});

0 comments on commit 705dcbc

Please sign in to comment.