Replace split Assets JS with a built bundle and aligned C#/config so SwarmUI loads one script and patch apply stays consistent; drop legacy terse persona and memory seed. Co-authored-by: Cursor <cursoragent@cursor.com>
38 lines
1.2 KiB
JavaScript
38 lines
1.2 KiB
JavaScript
import { describe, it } from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import {
|
|
extractPatch,
|
|
isPatchObject,
|
|
isCardObject,
|
|
normalizePatch,
|
|
setPatchKeys,
|
|
} from '../src/patch.js';
|
|
|
|
describe('patch.js', () => {
|
|
it('extractPatch finds generation patch in fence', () => {
|
|
const text = 'Here you go\n```json\n{"prompt":"A red fox in snow","actions":["generate"]}\n```';
|
|
const { prose, patch } = extractPatch(text);
|
|
assert.ok(patch);
|
|
assert.equal(patch.prompt, 'A red fox in snow');
|
|
assert.ok(!prose.includes('```'));
|
|
});
|
|
|
|
it('isCardObject vs isPatchObject', () => {
|
|
const card = { kind: 'lora', name: 'Foo', triggers: ['bar'] };
|
|
const gen = { prompt: 'test', actions: ['generate'] };
|
|
assert.equal(isCardObject(card), true);
|
|
assert.equal(isPatchObject(card), false);
|
|
assert.equal(isPatchObject(gen), true);
|
|
});
|
|
|
|
it('normalizePatch aliases civitai_query', () => {
|
|
const p = normalizePatch({ civitai_query: 'anime style' });
|
|
assert.equal(p.search_query, 'anime style');
|
|
});
|
|
|
|
it('scheduler-only patch is detected with full key list', () => {
|
|
setPatchKeys(['prompt', 'scheduler']);
|
|
assert.equal(isPatchObject({ scheduler: 'euler' }), true);
|
|
});
|
|
});
|