mirror of
https://github.com/Matysh/houseplan-card
synced 2026-09-29 03:09:36 +00:00
29 lines
932 B
JavaScript
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);
|
|
});
|