Skip to content

Commit

Permalink
chore: fix pluginManager mock
Browse files Browse the repository at this point in the history
  • Loading branch information
stijnvanhulle committed Mar 9, 2024
1 parent fb25317 commit 93a334e
Show file tree
Hide file tree
Showing 10 changed files with 21 additions and 10 deletions.
21 changes: 21 additions & 0 deletions packages/core/mocks/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { pascalCase } from '../src/transformers/casing.ts'

import { PluginManager } from '../src/PluginManager.ts'
import { readSync } from '../src/fs/read.ts'

export const mockedPluginManager = {
resolveName: ({ name, type }) => {
if (type === 'type') {
Expand All @@ -17,4 +19,23 @@ export const mockedPluginManager = {
on(eventName, args) {},
logLevel: 'info',
},
getFile: ({ name, extName, pluginKey }) => {
const baseName = `${name}${extName}`
let source = ''

try {
source = readSync(baseName)
} catch (_e) {
//
}

return {
path: baseName,
baseName,
meta: {
pluginKey,
},
source,
}
},
} as PluginManager
1 change: 0 additions & 1 deletion packages/swagger-client/src/components/Client.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ describe('<Client/>', async () => {

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

const Component = () => {
Expand Down
1 change: 0 additions & 1 deletion packages/swagger-faker/src/components/Mutation.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ describe('<Mutation/>', async () => {

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

const Component = () => {
Expand Down
1 change: 0 additions & 1 deletion packages/swagger-faker/src/components/Query.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ describe('<Query/>', async () => {

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

const Component = () => {
Expand Down
2 changes: 0 additions & 2 deletions packages/swagger-msw/src/components/Mock.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ describe('<Mock/>', async () => {

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

const Component = () => {
Expand All @@ -60,7 +59,6 @@ describe('<Mock/>', async () => {

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

const Component = () => {
Expand Down
1 change: 0 additions & 1 deletion packages/swagger-swr/src/components/Mutation.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ describe('<Mutation/>', async () => {

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

const Component = () => {
Expand Down
1 change: 0 additions & 1 deletion packages/swagger-swr/src/components/Query.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ describe('<Query/>', async () => {

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

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

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

const Component = () => {
Expand Down
1 change: 0 additions & 1 deletion packages/swagger-zod/src/components/Mutation.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ describe('<Mutation/>', async () => {

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

const Component = () => {
Expand Down
1 change: 0 additions & 1 deletion packages/swagger-zod/src/components/Query.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ describe('<Query/>', async () => {

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

const Component = () => {
Expand Down

0 comments on commit 93a334e

Please sign in to comment.