Commit 3a354558 authored by Robert Knight's avatar Robert Knight

Add test for calling `on` after `connect`

parent bb510f43
......@@ -146,4 +146,14 @@ describe('PortRPC', () => {
assert.notCalled(plusOne);
})
);
it('throws an error if `on` is called after `connect`', () => {
const { port1 } = new MessageChannel();
const rpc = new PortRPC();
rpc.connect(port1);
assert.throws(() => {
rpc.on('foo', () => {});
}, 'Cannot add a method handler after a port is connected');
});
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment