Spaces:
Paused
Paused
Download node_modules/msw/src/browser/utils/pruneGetRequestBody.test.ts from sam522/GenAI_Course: direct link, hf CLI and curl.
- Browser
- Download file 1.03 kB
-
https://huggingface.co/spaces/sam522/GenAI_Course/resolve/bbf0eafbb40cb551e2f40f8ad8a90a585be08221/node_modules/msw/src/browser/utils/pruneGetRequestBody.test.ts
- Command line
-
hf download hf://spaces/sam522/GenAI_Course@bbf0eafbb40cb551e2f40f8ad8a90a585be08221/node_modules/msw/src/browser/utils/pruneGetRequestBody.test.ts
-
curl -L -o pruneGetRequestBody.test.ts https://huggingface.co/spaces/sam522/GenAI_Course/resolve/bbf0eafbb40cb551e2f40f8ad8a90a585be08221/node_modules/msw/src/browser/utils/pruneGetRequestBody.test.ts
1.03 kB
| /** | |
| * @vitest-environment jsdom | |
| */ | |
| import { TextEncoder } from 'util' | |
| import { pruneGetRequestBody } from './pruneGetRequestBody' | |
| test('sets empty GET request body to undefined', () => { | |
| expect( | |
| pruneGetRequestBody({ | |
| method: 'GET', | |
| }), | |
| ).toBeUndefined() | |
| expect( | |
| pruneGetRequestBody({ | |
| method: 'GET', | |
| // There's no such thing as a GET request with a body. | |
| body: new ArrayBuffer(5), | |
| }), | |
| ).toBeUndefined() | |
| }) | |
| test('sets HEAD request body to undefined', () => { | |
| expect( | |
| pruneGetRequestBody({ | |
| method: 'HEAD', | |
| }), | |
| ).toBeUndefined() | |
| expect( | |
| pruneGetRequestBody({ | |
| method: 'HEAD', | |
| body: new ArrayBuffer(5), | |
| }), | |
| ).toBeUndefined() | |
| }) | |
| test('ignores requests of the other methods than GET', () => { | |
| const body = new TextEncoder().encode('hello world') | |
| expect( | |
| pruneGetRequestBody({ | |
| method: 'POST', | |
| body, | |
| }), | |
| ).toEqual(body) | |
| expect( | |
| pruneGetRequestBody({ | |
| method: 'PUT', | |
| body, | |
| }), | |
| ).toEqual(body) | |
| }) | |