Commit 3b1d7a43 authored by Eduardo Sanz García's avatar Eduardo Sanz García Committed by Eduardo

Remove `waitForMessageDelivery` in `rpc-bridge-test.js`

The test that used this utility function was failed randomly. It seems
that the `onConnect` callback is not always been triggered on the next
JS cycle.
parent bbe76799
...@@ -12,10 +12,6 @@ describe('PortRPC-Bridge integration', () => { ...@@ -12,10 +12,6 @@ describe('PortRPC-Bridge integration', () => {
return bridge; return bridge;
} }
function waitForMessageDelivery() {
return new Promise(resolve => setTimeout(resolve, 0));
}
beforeEach(() => { beforeEach(() => {
clock = sinon.useFakeTimers(); clock = sinon.useFakeTimers();
const channel = new MessageChannel(); const channel = new MessageChannel();
...@@ -30,9 +26,9 @@ describe('PortRPC-Bridge integration', () => { ...@@ -30,9 +26,9 @@ describe('PortRPC-Bridge integration', () => {
describe('establishing a connection', () => { describe('establishing a connection', () => {
it('should invoke Bridge `onConnect` callbacks after connecting', async () => { it('should invoke Bridge `onConnect` callbacks after connecting', async () => {
clock.restore();
const bridge = createBridge(); const bridge = createBridge();
const reciprocalBridge = createBridge(); const reciprocalBridge = createBridge();
reciprocalBridge.on('method', cb => cb(null));
let callbackCount = 0; let callbackCount = 0;
const callback = () => { const callback = () => {
++callbackCount; ++callbackCount;
...@@ -43,14 +39,14 @@ describe('PortRPC-Bridge integration', () => { ...@@ -43,14 +39,14 @@ describe('PortRPC-Bridge integration', () => {
const channel = bridge.createChannel(port1); const channel = bridge.createChannel(port1);
const reciprocalChannel = reciprocalBridge.createChannel(port2); const reciprocalChannel = reciprocalBridge.createChannel(port2);
await waitForMessageDelivery(); await bridge.call('method');
assert.equal(callbackCount, 3); assert.equal(callbackCount, 3);
// Additional calls to the RPC `connect` method are ignored // Additional calls to the RPC `connect` method are ignored
channel.call('connect'); await channel.call('connect');
reciprocalChannel.call('connect'); await reciprocalChannel.call('connect');
await waitForMessageDelivery(); await bridge.call('method');
assert.equal(callbackCount, 3); assert.equal(callbackCount, 3);
}); });
......
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