Download wp-calypso/client/state/selectors/test/get-current-route-parameterized.js from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 1.16 kB
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/state/selectors/test/get-current-route-parameterized.js
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/client/state/selectors/test/get-current-route-parameterized.js
-
curl -L -o get-current-route-parameterized.js https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/state/selectors/test/get-current-route-parameterized.js
1.16 kB
| 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' ); | |
| } ); | |
| } ); | |