@@ -5,6 +5,9 @@ import {describe, it} from '@jest/globals';
5
5
import { MemoryRouter } from 'react-router-dom' ;
6
6
import { useContactDialog } from '~/layouts/landing/footer/flex' ;
7
7
8
+ // @ts -expect-error does not exist on
9
+ const { routerFuture} = global ;
10
+
8
11
const user = userEvent . setup ( { advanceTimers : jest . advanceTimersByTime } ) ;
9
12
10
13
function ShowContactDialog ( props : Parameters < ReturnType < typeof useContactDialog > [ 'ContactDialog' ] > [ 0 ] ) {
@@ -23,15 +26,15 @@ describe('flex landing footer', () => {
23
26
beforeEach ( ( ) => {
24
27
jest . useFakeTimers ( ) ;
25
28
} ) ;
29
+ const getIframe = ( ) => document . querySelector ( 'iframe' ) ;
26
30
27
31
it ( 'opens and closes' , async ( ) => {
28
- const getIframe = ( ) => document . querySelector ( 'iframe' ) ;
29
32
const contactFormParams = [
30
33
{ key : 'userId' , value : 'test' }
31
34
] ;
32
35
33
36
render (
34
- < MemoryRouter initialEntries = { [ '' ] } >
37
+ < MemoryRouter initialEntries = { [ '' ] } future = { routerFuture } >
35
38
< ShowContactDialog contactFormParams = { contactFormParams } />
36
39
</ MemoryRouter >
37
40
) ;
@@ -48,5 +51,15 @@ describe('flex landing footer', () => {
48
51
window . postMessage ( 'CONTACT_FORM_SUBMITTED' , '*' ) ;
49
52
await waitFor ( ( ) => expect ( getIframe ( ) ) . toBeNull ( ) ) ;
50
53
} ) ;
54
+
55
+ it ( 'handles no contactFormParams' , async ( ) => {
56
+ render (
57
+ < MemoryRouter initialEntries = { [ '' ] } future = { routerFuture } >
58
+ < ShowContactDialog />
59
+ </ MemoryRouter >
60
+ ) ;
61
+ await user . click ( await screen . findByText ( 'Contact Us' ) ) ;
62
+ expect ( getIframe ( ) ?. src . endsWith ( '/contact' ) ) . toBe ( true ) ;
63
+ } ) ;
51
64
} ) ;
52
65
} ) ;
0 commit comments