|
| 1 | +/** |
| 2 | + * Generated by orval v8.20.0 🍺 |
| 3 | + * Do not edit manually. |
| 4 | + * Issue 3691 - tuple prefixItems mock |
| 5 | + * OpenAPI spec version: 1.0.0 |
| 6 | + */ |
| 7 | +import axios from 'axios'; |
| 8 | +import type { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios'; |
| 9 | + |
| 10 | +import type { Example } from './model'; |
| 11 | + |
| 12 | +import { faker } from '@faker-js/faker'; |
| 13 | + |
| 14 | +import { HttpResponse, http } from 'msw'; |
| 15 | +import type { RequestHandlerOptions } from 'msw'; |
| 16 | + |
| 17 | +export const getIssue3691TuplePrefixItemsMock = ( |
| 18 | + axiosInstance: AxiosInstance = axios, |
| 19 | +) => { |
| 20 | + const getExample = ( |
| 21 | + options?: AxiosRequestConfig, |
| 22 | + ): Promise<AxiosResponse<Example>> => { |
| 23 | + return axiosInstance.get(`/example`, options); |
| 24 | + }; |
| 25 | + |
| 26 | + return { getExample }; |
| 27 | +}; |
| 28 | +export type GetExampleResult = AxiosResponse<Example>; |
| 29 | + |
| 30 | +export const getGetExampleResponseMock = ( |
| 31 | + overrideResponse: Partial<Extract<Example, object>> = {}, |
| 32 | +): Example => ({ |
| 33 | + point: faker.helpers.arrayElement([ |
| 34 | + faker.helpers.arrayElement([ |
| 35 | + [ |
| 36 | + faker.number.float({ fractionDigits: 2 }), |
| 37 | + faker.number.float({ fractionDigits: 2 }), |
| 38 | + ], |
| 39 | + null, |
| 40 | + ]), |
| 41 | + undefined, |
| 42 | + ]), |
| 43 | + plainPoint: [ |
| 44 | + faker.number.float({ fractionDigits: 2 }), |
| 45 | + faker.string.alpha({ length: { min: 10, max: 20 } }), |
| 46 | + ], |
| 47 | + objTuple: [ |
| 48 | + { |
| 49 | + id: faker.helpers.arrayElement([ |
| 50 | + faker.string.alpha({ length: { min: 10, max: 20 } }), |
| 51 | + undefined, |
| 52 | + ]), |
| 53 | + }, |
| 54 | + faker.string.alpha({ length: { min: 10, max: 20 } }), |
| 55 | + ], |
| 56 | + restTuple: [ |
| 57 | + faker.string.alpha({ length: { min: 10, max: 20 } }), |
| 58 | + faker.number.float({ fractionDigits: 2 }), |
| 59 | + ], |
| 60 | + emptyElemTuple: [faker.string.alpha({ length: { min: 10, max: 20 } }), {}], |
| 61 | + ...overrideResponse, |
| 62 | +}); |
| 63 | + |
| 64 | +export const getGetExampleMockHandler = ( |
| 65 | + overrideResponse?: |
| 66 | + | Example |
| 67 | + | (( |
| 68 | + info: Parameters<Parameters<typeof http.get>[1]>[0], |
| 69 | + ) => Promise<Example> | Example), |
| 70 | + options?: RequestHandlerOptions, |
| 71 | +) => { |
| 72 | + return http.get( |
| 73 | + '*/example', |
| 74 | + async (info: Parameters<Parameters<typeof http.get>[1]>[0]) => { |
| 75 | + return HttpResponse.json( |
| 76 | + overrideResponse !== undefined |
| 77 | + ? typeof overrideResponse === 'function' |
| 78 | + ? await overrideResponse(info) |
| 79 | + : overrideResponse |
| 80 | + : getGetExampleResponseMock(), |
| 81 | + { status: 200 }, |
| 82 | + ); |
| 83 | + }, |
| 84 | + options, |
| 85 | + ); |
| 86 | +}; |
| 87 | +export const getIssue3691TuplePrefixItemsMockMock = () => [ |
| 88 | + getGetExampleMockHandler(), |
| 89 | +]; |
0 commit comments