mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-13 07:04:53 +09:00
Merge pull request #942 from Cooldude2606/refactor/sub-filters-again
Make SubscriberFilter extend Set and expose errors in EventSubscriber
This commit is contained in:
2 files changed
+60
-26
No files matched your search
@@ -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);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user