Basic settings screen
This commit is contained in:
@@ -1,60 +1,33 @@
|
||||
import { get } from "svelte/store";
|
||||
import configState, { Config2 } from "$lib/stores/configState"
|
||||
import configState, { type ConfigState } from "$lib/stores/configState"
|
||||
import { expect } from 'vitest';
|
||||
import UnitTest from "../UnitTest";
|
||||
import { Watch } from "@litegraph-ts/nodes-basic";
|
||||
|
||||
export default class configStateTests extends UnitTest {
|
||||
test__parse__parsesBasic() {
|
||||
const testConf = {
|
||||
backend: {
|
||||
comfyUIHostname: 'test',
|
||||
comfyUIPort: 8187,
|
||||
},
|
||||
behavior: {
|
||||
alwaysStripUserState: false,
|
||||
},
|
||||
};
|
||||
test__loadsDefaultsFromInvalid() {
|
||||
const saved = "foo"
|
||||
|
||||
expect(Config2.safeParse(testConf).success).toEqual(true);
|
||||
const config = configState.load(saved)
|
||||
expect(config).toBeInstanceOf(Object)
|
||||
expect(config.comfyUIHostname).toEqual("localhost")
|
||||
}
|
||||
|
||||
test__parse__parsesFallbacks() {
|
||||
const testConf = {
|
||||
backend: {},
|
||||
behavior: {}
|
||||
};
|
||||
test__loadsDefaultsFromBlank() {
|
||||
const saved = {}
|
||||
|
||||
const result = Config2.safeParse(testConf)
|
||||
|
||||
console.warn(result)
|
||||
expect(result.success).toEqual(true);
|
||||
expect(result.data).toEqual({
|
||||
backend: {
|
||||
comfyUIHostname: "localhost",
|
||||
comfyUIPort: 8188
|
||||
},
|
||||
behavior: {
|
||||
alwaysStripUserState: false
|
||||
}
|
||||
});
|
||||
const config = configState.load(saved)
|
||||
expect(config).toBeInstanceOf(Object)
|
||||
expect(config.comfyUIHostname).toEqual("localhost")
|
||||
}
|
||||
|
||||
test__parse__parsesFallbacks2() {
|
||||
const testConf = "foo";
|
||||
test__loadsDefaultsFromInvalidValues() {
|
||||
const saved = {
|
||||
comfyUIHostname: 1234 as any
|
||||
}
|
||||
|
||||
const result = Config2.safeParse(testConf)
|
||||
|
||||
console.warn(result)
|
||||
expect(result.success).toEqual(true);
|
||||
expect(result.data).toEqual({
|
||||
backend: {
|
||||
comfyUIHostname: "localhost",
|
||||
comfyUIPort: 8188
|
||||
},
|
||||
behavior: {
|
||||
alwaysStripUserState: false
|
||||
}
|
||||
});
|
||||
const config = configState.load(saved)
|
||||
expect(config).toBeInstanceOf(Object)
|
||||
expect(config.comfyUIHostname).toEqual("localhost")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user