Skip to content

Commit

Permalink
test stream metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
dmotz committed Feb 10, 2024
1 parent 424cfbd commit 3ddccf7
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions test/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,28 +61,32 @@ export default strategy =>
if (browserName !== 'webkit') {
// # onPeerStream()

const onPeerStream = () =>
const onPeerStream = streamMeta =>
new Promise(res => {
window.room.onPeerStream((_, peer) => res(peer))
window.room.onPeerStream((_, peerId, meta) => res({peerId, meta}))

setTimeout(
async () =>
window.room.addStream(
await navigator.mediaDevices.getUserMedia({
audio: true,
video: true
})
}),
null,
streamMeta
),
1000
)
})

const [peer2StreamId, peer1StreamId] = await Promise.all([
page.evaluate(onPeerStream),
page2.evaluate(onPeerStream)
const streamMeta = {id: Math.random()}
const [peer2StreamInfo, peer1StreamInfo] = await Promise.all([
page.evaluate(onPeerStream, streamMeta),
page2.evaluate(onPeerStream, streamMeta)
])

expect(peer1StreamId).toEqual(peer1Id)
expect(peer2StreamId).toEqual(peer2Id)
expect(peer1StreamInfo).toEqual({peerId: peer1Id, meta: streamMeta})
expect(peer2StreamInfo).toEqual({peerId: peer2Id, meta: streamMeta})
}

// # getPeers()
Expand Down

0 comments on commit 3ddccf7

Please sign in to comment.