Skip to content

Commit

Permalink
chore: revert pets test
Browse files Browse the repository at this point in the history
  • Loading branch information
stijnvanhulle committed Mar 7, 2024
1 parent ea1ccc2 commit 03dc141
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 4 deletions.
3 changes: 3 additions & 0 deletions packages/react/src/shared/ReactTemplate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ export class ReactTemplate<Context extends AppContextProps = AppContextProps> {
this.#lastFiles = files
}
onError(error: Error): void {
if (process.env.NODE_ENV === 'test') {
console.error(error)
}
if (!this.logger) {
console.error(error)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { FileManager } from '@kubb/core'
import { mockedPluginManager } from '@kubb/core/mocks'
import { OasManager } from '@kubb/swagger'

Expand All @@ -8,8 +7,7 @@ import { QueryKey } from './components/QueryKey.tsx'
import { QueryOptions } from './components/QueryOptions.tsx'
import { OperationGenerator } from './OperationGenerator.tsx'

import type { KubbFile } from '@kubb/core'
import type { Plugin } from '@kubb/core'
import { FileManager, KubbFile, type Plugin } from '@kubb/core'
import type { GetOperationGeneratorOptions } from '@kubb/swagger'
import type { PluginOptions } from './types.ts'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ describe('<Mutation/>', async () => {
)

test('pets', async () => {
const operation = oas.operation('/pets', 'post')
const operation = oas.operation('/pets/{uuid}', 'post')
const schemas = og.getSchemas(operation)
const context: AppContextProps<PluginOptions['appMeta']> = { meta: { oas, pluginManager: mockedPluginManager, plugin, schemas, operation } }

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
type CreatePetsClient = typeof client<CreatePetsMutationResponse, never, CreatePetsMutationRequest>
type CreatePets = {
data: CreatePetsMutationResponse
error: never
request: CreatePetsMutationRequest
pathParams: CreatePetsPathParams
queryParams: CreatePetsQueryParams
headerParams: CreatePetsHeaderParams

Check warning on line 8 in packages/swagger-tanstack-query/src/components/__snapshots__/Mutation/Pets.ts

View check run for this annotation

Codecov / codecov/patch

packages/swagger-tanstack-query/src/components/__snapshots__/Mutation/Pets.ts#L6-L8

Added lines #L6 - L8 were not covered by tests
response: CreatePetsMutationResponse
client: {
parameters: Partial<Parameters<CreatePetsClient>[0]>
return: Awaited<ReturnType<CreatePetsClient>>
}
}

/**
* @summary Create a pet
* @link /pets/:uuid */

Check warning on line 18 in packages/swagger-tanstack-query/src/components/__snapshots__/Mutation/Pets.ts

View check run for this annotation

Codecov / codecov/patch

packages/swagger-tanstack-query/src/components/__snapshots__/Mutation/Pets.ts#L18

Added line #L18 was not covered by tests

export function useCreatePets(

Check warning on line 20 in packages/swagger-tanstack-query/src/components/__snapshots__/Mutation/Pets.ts

View check run for this annotation

Codecov / codecov/patch

packages/swagger-tanstack-query/src/components/__snapshots__/Mutation/Pets.ts#L20

Added line #L20 was not covered by tests
options: {
mutation?: UseMutationOptions<
CreatePets['response'],
CreatePets['error'],
{ uuid: CreatePetsPathParams['uuid']; params?: CreatePets['queryParams']; headers: CreatePets['headerParams']; data: CreatePets['request'] }
>

Check warning on line 26 in packages/swagger-tanstack-query/src/components/__snapshots__/Mutation/Pets.ts

View check run for this annotation

Codecov / codecov/patch

packages/swagger-tanstack-query/src/components/__snapshots__/Mutation/Pets.ts#L22-L26

Added lines #L22 - L26 were not covered by tests
client?: CreatePets['client']['parameters']
} = {},
): UseMutationResult<
CreatePets['response'],
CreatePets['error'],
{ uuid: CreatePetsPathParams['uuid']; params?: CreatePets['queryParams']; headers: CreatePets['headerParams']; data: CreatePets['request'] }
> {
const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {}

Check warning on line 34 in packages/swagger-tanstack-query/src/components/__snapshots__/Mutation/Pets.ts

View check run for this annotation

Codecov / codecov/patch

packages/swagger-tanstack-query/src/components/__snapshots__/Mutation/Pets.ts#L29-L34

Added lines #L29 - L34 were not covered by tests

return useMutation<
CreatePets['response'],
CreatePets['error'],
{ uuid: CreatePetsPathParams['uuid']; params?: CreatePets['queryParams']; headers: CreatePets['headerParams']; data: CreatePets['request'] }
>({
mutationFn: async ({ uuid, headers, data, params }) => {
const res = await client<CreatePets['data'], CreatePets['error'], CreatePets['request']>({
method: 'post',
url: `/pets/${uuid}`,
params,
data,
headers: { ...headers, ...clientOptions.headers },
...clientOptions,
})

Check warning on line 49 in packages/swagger-tanstack-query/src/components/__snapshots__/Mutation/Pets.ts

View check run for this annotation

Codecov / codecov/patch

packages/swagger-tanstack-query/src/components/__snapshots__/Mutation/Pets.ts#L36-L49

Added lines #L36 - L49 were not covered by tests

return res.data
},
...mutationOptions,
})

Check warning on line 54 in packages/swagger-tanstack-query/src/components/__snapshots__/Mutation/Pets.ts

View check run for this annotation

Codecov / codecov/patch

packages/swagger-tanstack-query/src/components/__snapshots__/Mutation/Pets.ts#L51-L54

Added lines #L51 - L54 were not covered by tests
}

0 comments on commit 03dc141

Please sign in to comment.