1
- import React , { act } from 'react' ;
1
+ import React from 'react' ;
2
2
import { MockedProvider } from '@apollo/react-testing' ;
3
3
import { render } from '@testing-library/react' ;
4
4
import { Provider } from 'react-redux' ;
5
5
import { BrowserRouter } from 'react-router-dom' ;
6
- import 'jest-location-mock ';
6
+ import { vi , describe , test , expect } from 'vitest ';
7
7
import { I18nextProvider } from 'react-i18next' ;
8
8
9
9
import OrgContribution from './OrgContribution' ;
@@ -12,15 +12,19 @@ import i18nForTest from 'utils/i18nForTest';
12
12
import { StaticMockLink } from 'utils/StaticMockLink' ;
13
13
const link = new StaticMockLink ( [ ] , true ) ;
14
14
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 ) ;
19
17
} ) ;
20
18
}
21
19
22
20
describe ( 'Organisation Contribution Page' , ( ) => {
23
21
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
+ } ) ;
24
28
window . location . assign ( '/orglist' ) ;
25
29
26
30
const { container } = render (
@@ -37,11 +41,10 @@ describe('Organisation Contribution Page', () => {
37
41
38
42
expect ( container . textContent ) . not . toBe ( 'Loading data...' ) ;
39
43
await wait ( ) ;
40
-
41
44
expect ( container . textContent ) . toMatch ( 'Filter by Name' ) ;
42
45
expect ( container . textContent ) . toMatch ( 'Filter by Trans. ID' ) ;
43
46
expect ( container . textContent ) . toMatch ( 'Recent Stats' ) ;
44
47
expect ( container . textContent ) . toMatch ( 'Contribution' ) ;
45
- expect ( window . location ) . toBeAt ( '/orglist' ) ;
48
+ expect ( window . location . assign ) . toHaveBeenCalledWith ( '/orglist' ) ;
46
49
} ) ;
47
50
} ) ;
0 commit comments