Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/commands/docs/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ describe('docsCommand', () => {
if (originalIsTTY !== undefined) {
process.stdin.isTTY = originalIsTTY
} else {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
delete (process.stdin as any).isTTY
}
})
Expand Down
2 changes: 2 additions & 0 deletions src/commands/request/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ import { requestCommand } from './index.js'
describe('requestCommand', () => {
let program: Command
let consoleLogSpy: ReturnType<typeof vi.spyOn>
// eslint-disable-next-line @typescript-eslint/no-explicit-any
let mockModules: any
// eslint-disable-next-line @typescript-eslint/no-explicit-any
let mockBuildAndImportApp: any

const createBuildIterator = (app: Hono) => {
Expand Down
1 change: 1 addition & 0 deletions src/commands/search/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ export function searchCommand(program: Command) {
})
} else {
// Remove highlighted title from JSON output
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const jsonResults = results.map(({ highlightedTitle, ...result }) => result)
console.log(
JSON.stringify(
Expand Down
13 changes: 10 additions & 3 deletions src/commands/serve/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,25 +29,31 @@ import { serveCommand } from './index.js'

describe('serveCommand', () => {
let program: Command
let mockEsbuild: any
// eslint-disable-next-line @typescript-eslint/no-explicit-any
let mockModules: any
// eslint-disable-next-line @typescript-eslint/no-explicit-any
let mockServe: any
let mockShowRoutes: any
// eslint-disable-next-line @typescript-eslint/no-explicit-any
let capturedFetchFunction: any

beforeEach(async () => {
program = new Command()
serveCommand(program)

mockServe = vi.mocked((await import('@hono/node-server')).serve)
mockShowRoutes = vi.mocked((await import('hono/dev')).showRoutes)

mockModules = {
existsSync: vi.fn(),
resolve: vi.fn(),
}

mockModules = {
existsSync: vi.fn(),
resolve: vi.fn(),
}

// Capture the fetch function passed to serve
// eslint-disable-next-line @typescript-eslint/no-explicit-any
mockServe.mockImplementation((options: any, callback?: any) => {
capturedFetchFunction = options.fetch
if (callback) {
Expand Down Expand Up @@ -181,6 +187,7 @@ export default app
it('should handle typical use case: basicAuth + proxy to ramen-api.dev', async () => {
// Mock basicAuth middleware
const mockBasicAuth = vi.fn().mockImplementation(() => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
return async (c: any, next: any) => {
const auth = c.req.header('Authorization')
if (!auth || auth !== 'Basic aG9ubzpob25v') {
Expand Down
3 changes: 2 additions & 1 deletion src/commands/serve/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export function serveCommand(program: Command) {
}

// Import all builtin functions from the builtin map
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const allFunctions: Record<string, any> = {}
const uniqueModules = [...new Set(Object.values(builtinMap))]

Expand All @@ -74,7 +75,7 @@ export function serveCommand(program: Command) {
allFunctions[funcName] = module[funcName]
}
}
} catch (error) {
} catch {
// Skip modules that can't be imported (optional dependencies)
}
}
Expand Down
4 changes: 4 additions & 0 deletions src/utils/build.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,17 @@ vi.mock('node:url', () => ({
import { buildAndImportApp } from './build.js'

describe('buildAndImportApp', () => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
let mockEsbuildDispose: any
// eslint-disable-next-line @typescript-eslint/no-explicit-any
let mockEsbuild: any

const setupBundledCode = (code: string) => {
mockEsbuild.mockImplementation((param: Parameters<typeof context>[0]) => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
let onEnd: (result: any) => void
param.plugins?.[0].setup({
// eslint-disable-next-line @typescript-eslint/no-explicit-any
onEnd: (cb: (result: any) => void) => {
onEnd = cb
},
Expand Down