Skip to content

Commit

Permalink
Improve the close events test
Browse files Browse the repository at this point in the history
This primarily works around an issue with instant-close behaviour, but
also makes the test more accurate really, since later close is actually
what we're interested in, and because the previous test actually forced
a server-side close too weirdly.
  • Loading branch information
pimterry committed Dec 18, 2023
1 parent aa9493c commit e10fd15
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions test/integration/events.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ describe("MockRTC event subscriptions", function () {

const mockPeer = await mockRTC.buildPeer()
.waitForChannel()
.thenClose();
.thenEcho();

const localConnection = new RTCPeerConnection();
const dataChannel = localConnection.createDataChannel("test-channel");
Expand All @@ -366,7 +366,12 @@ describe("MockRTC event subscriptions", function () {
const { answer } = await mockPeer.answerOffer(localOffer);
await localConnection.setRemoteDescription(answer);

dataChannel.addEventListener('open', () => dataChannel.close());
dataChannel.addEventListener('open', () => {
// Work around https://github.com/murat-dogan/node-datachannel/issues/211
setTimeout(() => {
dataChannel.close();
}, 10);
});

const channelEvent = await eventPromise;
expect(channelEvent.peerId).to.equal(mockPeer.peerId);
Expand Down

0 comments on commit e10fd15

Please sign in to comment.