mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-20 06:20:11 +00:00
## Summary Enforced test file naming conventions with ESLint rules and renamed 26 test files from `.spec.ts` to `.test.ts`. ## Changes - **What**: Added ESLint rules to enforce `.spec.ts` files only in `browser_tests/tests/` and `.test.ts` files only in `src/` - **What**: Renamed 26 component/unit test files from `.spec.ts` to `.test.ts` to comply with new convention ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-5820-enforce-test-file-naming-rule-27b6d73d365081269b32ddcc9d3a5048) by [Unito](https://www.unito.io)
75 lines
1.9 KiB
TypeScript
75 lines
1.9 KiB
TypeScript
import { mount } from '@vue/test-utils'
|
|
import { createPinia } from 'pinia'
|
|
import PrimeVue from 'primevue/config'
|
|
import Tag from 'primevue/tag'
|
|
import Tooltip from 'primevue/tooltip'
|
|
import { describe, expect, it, vi } from 'vitest'
|
|
import { createI18n } from 'vue-i18n'
|
|
|
|
import SettingItem from '@/platform/settings/components/SettingItem.vue'
|
|
|
|
const i18n = createI18n({
|
|
legacy: false,
|
|
locale: 'en'
|
|
})
|
|
|
|
vi.mock('@/utils/formatUtil', () => ({
|
|
normalizeI18nKey: vi.fn()
|
|
}))
|
|
|
|
describe('SettingItem', () => {
|
|
const mountComponent = (props: any, options = {}): any => {
|
|
return mount(SettingItem, {
|
|
global: {
|
|
plugins: [PrimeVue, i18n, createPinia()],
|
|
components: {
|
|
Tag
|
|
},
|
|
directives: {
|
|
tooltip: Tooltip
|
|
},
|
|
stubs: {
|
|
'i-material-symbols:experiment-outline': true
|
|
}
|
|
},
|
|
props,
|
|
...options
|
|
})
|
|
}
|
|
|
|
it('translates options that use legacy type', () => {
|
|
const wrapper = mountComponent({
|
|
setting: {
|
|
id: 'Comfy.NodeInputConversionSubmenus',
|
|
name: 'Node Input Conversion Submenus',
|
|
type: 'combo',
|
|
value: 'Top',
|
|
options: () => ['Correctly Translated']
|
|
}
|
|
})
|
|
|
|
// Get the options property of the FormItem
|
|
const options = wrapper.vm.formItem.options
|
|
expect(options).toEqual([
|
|
{ text: 'Correctly Translated', value: 'Correctly Translated' }
|
|
])
|
|
})
|
|
|
|
it('handles tooltips with @ symbols without errors', () => {
|
|
const wrapper = mountComponent({
|
|
setting: {
|
|
id: 'TestSetting',
|
|
name: 'Test Setting',
|
|
type: 'boolean',
|
|
tooltip:
|
|
'This will load a larger version of @mtb/markdown-parser that bundles shiki'
|
|
}
|
|
})
|
|
|
|
// Should not throw an error and tooltip should be preserved as-is
|
|
expect(wrapper.vm.formItem.tooltip).toBe(
|
|
'This will load a larger version of @mtb/markdown-parser that bundles shiki'
|
|
)
|
|
})
|
|
})
|