Skip to content

Commit dfea1d5

Browse files
committed
Fix coverage on landing/footer test
1 parent acb749b commit dfea1d5

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

test/src/layouts/landing/footer.test.tsx

+15-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ import {describe, it} from '@jest/globals';
55
import { MemoryRouter } from 'react-router-dom';
66
import { useContactDialog } from '~/layouts/landing/footer/flex';
77

8+
// @ts-expect-error does not exist on
9+
const {routerFuture} = global;
10+
811
const user = userEvent.setup({advanceTimers: jest.advanceTimersByTime});
912

1013
function ShowContactDialog(props: Parameters<ReturnType<typeof useContactDialog>['ContactDialog']>[0]) {
@@ -23,15 +26,15 @@ describe('flex landing footer', () => {
2326
beforeEach(() => {
2427
jest.useFakeTimers();
2528
});
29+
const getIframe = () => document.querySelector('iframe');
2630

2731
it('opens and closes', async () => {
28-
const getIframe = () => document.querySelector('iframe');
2932
const contactFormParams = [
3033
{ key: 'userId', value: 'test' }
3134
];
3235

3336
render(
34-
<MemoryRouter initialEntries={['']}>
37+
<MemoryRouter initialEntries={['']} future={routerFuture}>
3538
<ShowContactDialog contactFormParams={contactFormParams} />
3639
</MemoryRouter>
3740
);
@@ -48,5 +51,15 @@ describe('flex landing footer', () => {
4851
window.postMessage('CONTACT_FORM_SUBMITTED', '*');
4952
await waitFor(() => expect(getIframe()).toBeNull());
5053
});
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+
});
5164
});
5265
});

0 commit comments

Comments
 (0)