Files
houseplan-card/test/editor-secondary.test.mjs
2026-09-01 22:23:57 +03:00

29 lines
932 B
JavaScript

import assert from 'node:assert/strict';
import test from 'node:test';
import { EditorSecondaryController } from '../test-build/editor-secondary.js';
const host = {
root: () => ({}),
requestUpdate() {},
async updateComplete() {},
clearTip() {},
};
test('editor secondary context returns the current action result and rejects stale actions (#405)', async () => {
const controller = new EditorSecondaryController(host);
assert.equal(controller.runContext('current', 'current', () => 42), 42);
const pending = Promise.resolve('finished');
assert.equal(controller.runContext('current', 'current', () => pending), pending);
assert.equal(await controller.runContext('current', 'current', () => pending), 'finished');
let staleCalled = false;
assert.equal(controller.runContext('old', 'current', () => {
staleCalled = true;
return 'unexpected';
}), undefined);
assert.equal(staleCalled, false);
});