Add type parameters to vi.fn() mocks for oxlint 1.60 vitest rule
oxlint 1.60 enables vitest/require-mock-type-parameters by default, which requires explicit type parameters on all vi.fn() calls. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -3,19 +3,20 @@ import { mount, flushPromises } from '@vue/test-utils'
|
||||
import { createRouter, createMemoryHistory } from 'vue-router'
|
||||
import EventCreateView from '../EventCreateView.vue'
|
||||
import { api } from '@/api/client'
|
||||
import type { StoredEvent } from '@/composables/useEventStorage'
|
||||
vi.mock('@/api/client', () => ({
|
||||
api: {
|
||||
POST: vi.fn(),
|
||||
POST: vi.fn<typeof api.POST>(),
|
||||
},
|
||||
}))
|
||||
|
||||
vi.mock('@/composables/useEventStorage', () => ({
|
||||
useEventStorage: vi.fn(() => ({
|
||||
saveCreatedEvent: vi.fn(),
|
||||
getStoredEvents: vi.fn(() => []),
|
||||
getOrganizerToken: vi.fn(),
|
||||
saveRsvp: vi.fn(),
|
||||
getRsvp: vi.fn(),
|
||||
useEventStorage: vi.fn<() => unknown>(() => ({
|
||||
saveCreatedEvent: vi.fn<() => void>(),
|
||||
getStoredEvents: vi.fn<() => unknown[]>(() => []),
|
||||
getOrganizerToken: vi.fn<() => string | undefined>(),
|
||||
saveRsvp: vi.fn<() => void>(),
|
||||
getRsvp: vi.fn<() => unknown>(),
|
||||
})),
|
||||
}))
|
||||
|
||||
@@ -154,19 +155,19 @@ describe('EventCreateView', () => {
|
||||
})
|
||||
|
||||
it('submits successfully, saves to storage, and navigates to event page', async () => {
|
||||
const mockSave = vi.fn()
|
||||
const mockSave = vi.fn<(...args: unknown[]) => void>()
|
||||
vi.mocked(vi.importActual<typeof import('@/composables/useEventStorage')>)
|
||||
const { useEventStorage } = await import('@/composables/useEventStorage')
|
||||
vi.mocked(useEventStorage).mockReturnValue({
|
||||
saveCreatedEvent: mockSave,
|
||||
getStoredEvents: vi.fn(() => []),
|
||||
getOrganizerToken: vi.fn(),
|
||||
saveRsvp: vi.fn(),
|
||||
getRsvp: vi.fn(),
|
||||
removeRsvp: vi.fn(),
|
||||
saveWatch: vi.fn(),
|
||||
isStored: vi.fn(() => false),
|
||||
removeEvent: vi.fn(),
|
||||
getStoredEvents: vi.fn<() => StoredEvent[]>(() => []),
|
||||
getOrganizerToken: vi.fn<() => string | undefined>(),
|
||||
saveRsvp: vi.fn<() => void>(),
|
||||
getRsvp: vi.fn<() => { rsvpToken: string; rsvpName: string } | undefined>(),
|
||||
removeRsvp: vi.fn<() => void>(),
|
||||
saveWatch: vi.fn<() => void>(),
|
||||
isStored: vi.fn<() => boolean>(() => false),
|
||||
removeEvent: vi.fn<() => void>(),
|
||||
})
|
||||
|
||||
vi.mocked(api.POST).mockResolvedValueOnce({
|
||||
|
||||
Reference in New Issue
Block a user