react-code-dataset / next.js /packages /next /src /client /components /router-reducer /create-href-from-url.test.ts
Download next.js/packages/next/src/client/components/router-reducer/create-href-from-url.test.ts from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 840 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/next.js/packages/next/src/client/components/router-reducer/create-href-from-url.test.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/next.js/packages/next/src/client/components/router-reducer/create-href-from-url.test.ts
-
curl -L -o create-href-from-url.test.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/next.js/packages/next/src/client/components/router-reducer/create-href-from-url.test.ts
840 Bytes
| import { createHrefFromUrl } from './create-href-from-url' | |
| describe('createHrefFromUrl', () => { | |
| it('returns a string', () => { | |
| const url = new URL('https://example.com/') | |
| expect(createHrefFromUrl(url)).toBe('/') | |
| }) | |
| it('adds hash', () => { | |
| const url = new URL('https://example.com/#hash') | |
| expect(createHrefFromUrl(url)).toBe('/#hash') | |
| }) | |
| it('adds searchParams', () => { | |
| const url = new URL('https://example.com/?a=1&b=2') | |
| expect(createHrefFromUrl(url)).toBe('/?a=1&b=2') | |
| }) | |
| it('adds pathname', () => { | |
| const url = new URL('https://example.com/path') | |
| expect(createHrefFromUrl(url)).toBe('/path') | |
| }) | |
| it('adds pathname, searchParams, and hash', () => { | |
| const url = new URL('https://example.com/path?a=1&b=2#hash') | |
| expect(createHrefFromUrl(url)).toBe('/path?a=1&b=2#hash') | |
| }) | |
| }) | |