File tree 1 file changed +48
-0
lines changed
1 file changed +48
-0
lines changed Original file line number Diff line number Diff line change
1
+ import Resolver from "./Resolver" ;
2
+ import React from "react" ;
3
+ import { unmountComponentAtNode } from "react-dom" ;
4
+ import { act } from "react-dom/test-utils" ;
5
+ import { render , screen } from '@testing-library/react' ;
6
+ import { BrowserRouter } from "react-router-dom" ;
7
+
8
+ const mockUrlParams = ( slug ) => {
9
+ return {
10
+ params : {
11
+ slug : slug ,
12
+ }
13
+ }
14
+ } ;
15
+
16
+ let container = null ;
17
+ beforeEach ( ( ) => {
18
+ // setup a DOM element as a render target
19
+ container = document . createElement ( "div" ) ;
20
+ document . body . appendChild ( container ) ;
21
+
22
+ act ( ( ) => {
23
+ render ( < Resolver match = { mockUrlParams ( 'random-slug' ) } /> , {
24
+ container : container ,
25
+ wrapper : BrowserRouter
26
+ } ) ;
27
+ } ) ;
28
+ } ) ;
29
+
30
+ afterEach ( ( ) => {
31
+ // cleanup on exiting
32
+ unmountComponentAtNode ( container ) ;
33
+ container . remove ( ) ;
34
+ container = null ;
35
+ } ) ;
36
+
37
+ test ( 'renders' , ( ) => {
38
+ const redirectionText = screen . getByText ( / R e d i r e c t i n g / i) ;
39
+ expect ( redirectionText ) . toBeInTheDocument ( ) ;
40
+ } ) ;
41
+
42
+ xtest ( 'redirects' , ( ) => {
43
+ // TODO
44
+ } ) ;
45
+
46
+ xtest ( 'displays incorrect URL warning' , ( ) => {
47
+ // TODO
48
+ } ) ;
You can’t perform that action at this time.
0 commit comments