Download wp-calypso/client/landing/stepper/hooks/test/helpers/nock.ts from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 984 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/landing/stepper/hooks/test/helpers/nock.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/client/landing/stepper/hooks/test/helpers/nock.ts
-
curl -L -o nock.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/landing/stepper/hooks/test/helpers/nock.ts
984 Bytes
| /** | |
| * Helper to support nock reply responses using the correct envelope format. | |
| * Requests with envelope http_envelope=1 require a specific response format. | |
| * @example | |
| * const installationWithSuccess = replyWithEnvelope( 200 ); | |
| * const installationWithError = replyWithEnvelope( 400, { error: 'any error' } ); | |
| * | |
| * nock(...).reply(installationWithSuccess() ); | |
| * nock(...).reply(installationWithError({error: 'any other error'}) ); | |
| */ | |
| export const replyWithEnvelope = | |
| ( status: number, defaultBody: Record< string, string | number > = {} ) => | |
| ( body = {} ) => | |
| () => [ status, { code: status, ...defaultBody, ...body } ]; | |
| export const replyErrorWithEnvelope = | |
| ( status: number, defaultBody: Record< string, string | number > = {} ) => | |
| ( body = {} ) => | |
| () => [ 200, { code: status, body: { ...defaultBody, ...body } } ]; | |
| export const replyWithSuccess = replyWithEnvelope( 200 ); | |
| export const replyWithError = replyErrorWithEnvelope( 400, { error: 'any error' } ); | |