File size: 1,159 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import getCurrentRouteParameterized from 'calypso/state/selectors/get-current-route-parameterized';

describe( 'getCurrentRouteParameterized()', () => {
	const route = {
		path: {
			current: '/test/url/testsite.blog',
		},
	};

	const sites = {
		items: { 12345: { URL: 'http://testsite.blog' } },
	};

	test( 'it returns null when state is missing the path', () => {
		const state = {
			route: {},
			sites: sites,
		};

		expect( getCurrentRouteParameterized( state, 12345 ) ).toBeNull();
	} );

	test( 'it returns null when state is missing the site', () => {
		const state = {
			route,
			sites: { items: {} },
		};

		expect( getCurrentRouteParameterized( state, 12345 ) ).toBeNull();
	} );

	test( 'it replaces the site slug with :site', () => {
		const state = {
			route,
			sites,
		};

		expect( getCurrentRouteParameterized( state, 12345 ) ).toEqual( '/test/url/:site' );
	} );

	test( 'it replaces the site ID with :siteid', () => {
		const state = {
			route: {
				path: {
					current: '/test/url/12345',
				},
			},
			sites: sites,
		};

		expect( getCurrentRouteParameterized( state, 12345 ) ).toEqual( '/test/url/:siteid' );
	} );
} );