Move setting impl from ComfySettingsDialog to settingStore (#2085)

This commit is contained in:
Chenlei Hu
2024-12-28 21:31:09 -05:00
committed by GitHub
parent 5152985656
commit a48ad1cb41
10 changed files with 299 additions and 188 deletions

View File

@@ -1,6 +1,4 @@
// @ts-strict-ignore
import type { ComfySettingsDialog } from '@/scripts/ui/settings'
import type { ComfyApp } from '@/scripts/app'
import '../../src/scripts/api'
import { ComfyNodeDef } from '@/types/apiTypes'
@@ -98,31 +96,6 @@ export function mockApi(config: APIConfig = {}) {
}))
}
export const mockSettingStore = () => {
let app: ComfyApp | null = null
const mockedSettingStore = {
addSettings(settings: ComfySettingsDialog) {
app = settings.app
},
set(key: string, value: any) {
app?.ui.settings.setSettingValue(key, value)
},
get(key: string) {
return (
app?.ui.settings.getSettingValue(key) ??
app?.ui.settings.getSettingDefaultValue(key)
)
}
}
jest.mock('@/stores/settingStore', () => ({
useSettingStore: jest.fn(() => mockedSettingStore)
}))
}
export const mockNodeDefStore = () => {
const mockedNodeDefStore = {
addNodeDef: jest.fn((nodeDef: ComfyNodeDef) => {})