From 88fb21194f07a3fd8ce487d6a762cd4977ea07d3 Mon Sep 17 00:00:00 2001 From: Johnpaul Date: Wed, 21 Jan 2026 02:41:31 +0100 Subject: [PATCH] test: remove any type from SettingItem test mountComponent helper - Replace `props: any` and return type with proper types - Use Record with ComponentProps cast - Refactor tests to check FormItem component props instead of internal state - Import ComponentProps from vue-component-type-helpers Part of Phase 2 - Quick wins (1 instance removed) --- .../dialog/content/setting/SettingItem.test.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/components/dialog/content/setting/SettingItem.test.ts b/src/components/dialog/content/setting/SettingItem.test.ts index 17e3bab06..f1cfd5638 100644 --- a/src/components/dialog/content/setting/SettingItem.test.ts +++ b/src/components/dialog/content/setting/SettingItem.test.ts @@ -1,3 +1,5 @@ +import type { ComponentProps } from 'vue-component-type-helpers' + import { mount } from '@vue/test-utils' import { createPinia } from 'pinia' import PrimeVue from 'primevue/config' @@ -18,7 +20,7 @@ vi.mock('@/utils/formatUtil', () => ({ })) describe('SettingItem', () => { - const mountComponent = (props: any, options = {}): any => { + const mountComponent = (props: Record, options = {}) => { return mount(SettingItem, { global: { plugins: [PrimeVue, i18n, createPinia()], @@ -32,7 +34,7 @@ describe('SettingItem', () => { 'i-material-symbols:experiment-outline': true } }, - props, + props: props as unknown as ComponentProps, ...options }) } @@ -48,8 +50,9 @@ describe('SettingItem', () => { } }) - // Get the options property of the FormItem - const options = wrapper.vm.formItem.options + // Check the FormItem component's item prop for the options + const formItem = wrapper.findComponent({ name: 'FormItem' }) + const options = formItem.props('item').options expect(options).toEqual([ { text: 'Correctly Translated', value: 'Correctly Translated' } ]) @@ -67,7 +70,8 @@ describe('SettingItem', () => { }) // Should not throw an error and tooltip should be preserved as-is - expect(wrapper.vm.formItem.tooltip).toBe( + const formItem = wrapper.findComponent({ name: 'FormItem' }) + expect(formItem.props('item').tooltip).toBe( 'This will load a larger version of @mtb/markdown-parser that bundles shiki' ) })