mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-29 02:32:18 +00:00
Fix remote widget undefined arg (#2551)
This commit is contained in:
44
tests-ui/tests/composables/widgets/useComboWidget.test.ts
Normal file
44
tests-ui/tests/composables/widgets/useComboWidget.test.ts
Normal file
@@ -0,0 +1,44 @@
|
||||
import { createPinia, setActivePinia } from 'pinia'
|
||||
|
||||
import { useComboWidget } from '@/composables/widgets/useComboWidget'
|
||||
import type { InputSpec } from '@/types/apiTypes'
|
||||
|
||||
jest.mock('@/scripts/widgets', () => ({
|
||||
addValueControlWidgets: jest.fn()
|
||||
}))
|
||||
|
||||
describe('useComboWidget', () => {
|
||||
beforeEach(() => {
|
||||
setActivePinia(createPinia())
|
||||
jest.clearAllMocks()
|
||||
})
|
||||
|
||||
it('should handle undefined spec', () => {
|
||||
const constructor = useComboWidget()
|
||||
const mockNode = {
|
||||
addWidget: jest.fn().mockReturnValue({ options: {} } as any)
|
||||
}
|
||||
|
||||
const inputSpec: InputSpec = ['COMBO', undefined]
|
||||
|
||||
const widget = constructor(
|
||||
mockNode as any,
|
||||
'inputName',
|
||||
inputSpec,
|
||||
undefined as any
|
||||
)
|
||||
|
||||
expect(mockNode.addWidget).toHaveBeenCalledWith(
|
||||
'combo',
|
||||
'inputName',
|
||||
undefined, // default value
|
||||
expect.any(Function), // callback
|
||||
expect.objectContaining({
|
||||
values: 'COMBO'
|
||||
})
|
||||
)
|
||||
expect(widget).toEqual({
|
||||
widget: { options: {} }
|
||||
})
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user