Download next.js/packages/next/src/shared/lib/router/utils/prepare-destination.test.ts from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 1.86 kB
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/next.js/packages/next/src/shared/lib/router/utils/prepare-destination.test.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/next.js/packages/next/src/shared/lib/router/utils/prepare-destination.test.ts
-
curl -L -o prepare-destination.test.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/next.js/packages/next/src/shared/lib/router/utils/prepare-destination.test.ts
1.86 kB
| import { parseDestination } from './prepare-destination' | |
| describe('parseDestination', () => { | |
| it('should parse the destination', () => { | |
| const destination = '/hello/:name' | |
| const params = { name: 'world' } | |
| const query = { foo: 'bar' } | |
| const result = parseDestination({ | |
| destination, | |
| params, | |
| query, | |
| }) | |
| expect(result).toMatchInlineSnapshot(` | |
| { | |
| "hash": "", | |
| "hostname": undefined, | |
| "href": "/hello/:name", | |
| "pathname": "/hello/:name", | |
| "query": {}, | |
| "search": "", | |
| "slashes": undefined, | |
| } | |
| `) | |
| }) | |
| it('should parse the destination with a hash', () => { | |
| const destination = 'https://o:foo.com/hello/:name#bar' | |
| const params = { name: 'world' } | |
| const query = { foo: 'bar' } | |
| const result = parseDestination({ | |
| destination, | |
| params, | |
| query, | |
| }) | |
| expect(result).toMatchInlineSnapshot(` | |
| { | |
| "hash": "#bar", | |
| "hostname": "o:foo.com", | |
| "href": "https://o:foo.com/hello/:name#bar", | |
| "pathname": "/hello/:name", | |
| "port": "", | |
| "protocol": "https:", | |
| "query": {}, | |
| "search": "", | |
| "slashes": true, | |
| } | |
| `) | |
| }) | |
| it('should parse the destination with a host', () => { | |
| const destination = 'https://o:foo.com/hello/:name?foo=:bar' | |
| const params = { name: 'world' } | |
| const query = { foo: 'bar' } | |
| const result = parseDestination({ | |
| destination, | |
| params, | |
| query, | |
| }) | |
| expect(result).toMatchInlineSnapshot(` | |
| { | |
| "hash": "", | |
| "hostname": "o:foo.com", | |
| "href": "https://o:foo.com/hello/:name?foo=:bar", | |
| "pathname": "/hello/:name", | |
| "port": "", | |
| "protocol": "https:", | |
| "query": { | |
| "foo": ":bar", | |
| }, | |
| "search": "?foo=:bar", | |
| "slashes": true, | |
| } | |
| `) | |
| }) | |
| }) | |