Merge pull request #942 from Cooldude2606/refactor/sub-filters-again

Make SubscriberFilter extend Set and expose errors in EventSubscriber
This commit is contained in:
Cooldude2606 authored and GitHub committed 2026-07-08 08:30:37 +01:00
commit 07fcdb0d4e
2 files changed
+60 -26

No files matched your search

+23 -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,25 @@ 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.ok(error1 instanceof lib.PermissionError);
assert.equal(error1.message, "Permission denied");
assert.equal(error1.code, "PermissionError");
eventSubscriber.control.sendTo = function() {};
unsubscribe();
await new Promise(r => setImmediate(r));
const [,, error2] = eventSubscriber.getSnapshot();
assert.deepEqual(error2, null);
});
});
});