mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-30 03:01:54 +00:00
test: remove any type from BaseTerminal test mock access
- Replace `as any` with proper `Mock` type from vitest - Import Mock type and access mock.calls with type safety - Explicitly type selectionCallback as `() => void` - Break down mock access into steps for clarity Part of Phase 2 - Quick wins (1 instance removed)
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
import { createTestingPinia } from '@pinia/testing'
|
import { createTestingPinia } from '@pinia/testing'
|
||||||
import type { VueWrapper } from '@vue/test-utils'
|
import type { VueWrapper } from '@vue/test-utils'
|
||||||
import { mount } from '@vue/test-utils'
|
import { mount } from '@vue/test-utils'
|
||||||
|
import type { Mock } from 'vitest'
|
||||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||||
import { nextTick } from 'vue'
|
import { nextTick } from 'vue'
|
||||||
import { createI18n } from 'vue-i18n'
|
import { createI18n } from 'vue-i18n'
|
||||||
@@ -151,8 +152,8 @@ describe('BaseTerminal', () => {
|
|||||||
// Trigger the selection change callback that was registered during mount
|
// Trigger the selection change callback that was registered during mount
|
||||||
expect(mockTerminal.onSelectionChange).toHaveBeenCalled()
|
expect(mockTerminal.onSelectionChange).toHaveBeenCalled()
|
||||||
// Access the mock calls - TypeScript can't infer the mock structure dynamically
|
// Access the mock calls - TypeScript can't infer the mock structure dynamically
|
||||||
const selectionCallback = (mockTerminal.onSelectionChange as any).mock
|
const mockCalls = (mockTerminal.onSelectionChange as Mock).mock.calls
|
||||||
.calls[0][0]
|
const selectionCallback = mockCalls[0][0] as () => void
|
||||||
selectionCallback()
|
selectionCallback()
|
||||||
await nextTick()
|
await nextTick()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user