Expose error on event subscriber snapshot

This commit is contained in:
Cooldude2606 committed 2026-06-26 22:04:06 +01:00
1 parent e135d37878
commit 95ea073b77
2 files changed
+36 -6

No files matched your search

+21 -1
View File
@@ -792,7 +792,10 @@ describe("lib/subscriptions", function() {
});
describe("class EventSubscriber", function() {
let mockControl, eventSubscriber;
/** @type {MockControl} */
let mockControl;
/** @type {lib.EventSubscriber} */
let eventSubscriber;
beforeEach(function() {
mockControl = new MockControl(new MockConnector(
@@ -1120,6 +1123,23 @@ describe("lib/subscriptions", function() {
}
assert.equal(logged, undefined);
});
it("should expose errors through the snapshot", async function() {
eventSubscriber.control.sendTo = function() {
throw new lib.PermissionError("Permission denied");
};
const unsubscribe = eventSubscriber.subscribe(() => {});
await new Promise(r => setImmediate(r));
const [,, error1] = eventSubscriber.getSnapshot();
assert.deepEqual(error1, new lib.PermissionError("Permission denied"));
eventSubscriber.control.sendTo = function() {};
unsubscribe();
await new Promise(r => setImmediate(r));
const [,, error2] = eventSubscriber.getSnapshot();
assert.deepEqual(error2, null);
});
});
});