File size: 559 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
/**
 * @jest-environment jsdom
 */
import { renderHook } from '@testing-library/react';
import { useSiteIdParam } from '../use-site-id-param';

jest.mock( 'react-router-dom', () => ( {
	useLocation: jest.fn().mockImplementation( () => ( {
		pathname: '/setup',
		search: '?siteId=2053432885',
		hash: '',
		state: undefined,
	} ) ),
} ) );

describe( 'use-site-id-param hook', () => {
	test( 'returns site id if provided', async () => {
		const { result } = renderHook( () => useSiteIdParam() );
		expect( result.current ).toEqual( '2053432885' );
	} );
} );