1
1
import { render , screen , waitFor } from "@testing-library/react" ;
2
2
import userEvent from "@testing-library/user-event" ;
3
3
import React from "react" ;
4
- import { FormattedMessage } from "react-intl" ;
5
4
import { Routes , Route , Link } from "react-router-dom" ;
6
5
import configureStore from "redux-mock-store" ;
7
6
@@ -13,7 +12,7 @@ const initialState = {
13
12
runtime : {
14
13
entrypoint : null ,
15
14
} ,
16
- shared : { } ,
15
+ env : { } ,
17
16
} ;
18
17
19
18
const mockStore = configureStore ( [ ] ) ;
@@ -24,7 +23,7 @@ class ErrorBoundary extends React.Component {
24
23
this . state = false ;
25
24
}
26
25
27
- static getDerivedStateFromError ( error ) {
26
+ static getDerivedStateFromError ( _error ) {
28
27
return true ;
29
28
}
30
29
@@ -43,11 +42,11 @@ const BrokenComponent = () => {
43
42
44
43
describe ( "<Entrypoint />" , ( ) => {
45
44
beforeEach ( ( ) => {
46
- window . history . pushState ( null , document . title , "/" ) ;
45
+ top . history . pushState ( null , document . title , "/" ) ;
47
46
} ) ;
48
47
49
48
afterEach ( ( ) => {
50
- window . history . pushState ( null , document . title , "/" ) ;
49
+ top . history . pushState ( null , document . title , "/" ) ;
51
50
} ) ;
52
51
53
52
it ( "entrypoint missing" , ( ) => {
@@ -98,7 +97,7 @@ describe("<Entrypoint />", () => {
98
97
await userEvent . click ( screen . getByText ( "Navigate" ) ) ;
99
98
100
99
await waitFor ( ( ) => {
101
- expect ( window . location . pathname ) . toBe ( "/404" ) ;
100
+ expect ( top . location . pathname ) . toBe ( "/404" ) ;
102
101
expect ( screen . getByTestId ( "RouteNoMatch" ) ) . toBeInTheDocument ( ) ;
103
102
} ) ;
104
103
@@ -107,7 +106,7 @@ describe("<Entrypoint />", () => {
107
106
await userEvent . click ( screen . getByText ( "Navigate" ) ) ;
108
107
109
108
await waitFor ( ( ) => {
110
- expect ( window . location . pathname ) . toBe ( "/grand/parent/child" ) ;
109
+ expect ( top . location . pathname ) . toBe ( "/grand/parent/child" ) ;
111
110
expect ( screen . getByTestId ( "RouteMatchLeft" ) ) . toBeInTheDocument ( ) ;
112
111
} ) ;
113
112
@@ -116,7 +115,7 @@ describe("<Entrypoint />", () => {
116
115
await userEvent . click ( screen . getByText ( "Navigate" ) ) ;
117
116
118
117
await waitFor ( ( ) => {
119
- expect ( window . location . pathname ) . toBe ( "/sibling" ) ;
118
+ expect ( top . location . pathname ) . toBe ( "/sibling" ) ;
120
119
expect ( screen . getByTestId ( "RouteMatchRight" ) ) . toBeInTheDocument ( ) ;
121
120
} ) ;
122
121
} ) ;
0 commit comments