Skip to content

Commit dc2e0bb

Browse files
committed
Enhance get_local_description test
1 parent a8ae140 commit dc2e0bb

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

test/ex_webrtc/peer_connection_test.exs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,8 @@ defmodule ExWebRTC.PeerConnectionTest do
238238
describe "get_local_description/1" do
239239
test "includes ICE candidates" do
240240
{:ok, pc} = PeerConnection.start()
241-
{:ok, _sender} = PeerConnection.add_transceiver(pc, :audio)
241+
{:ok, _tr} = PeerConnection.add_transceiver(pc, :audio)
242+
{:ok, _tr} = PeerConnection.add_transceiver(pc, :video)
242243
{:ok, offer} = PeerConnection.create_offer(pc)
243244
:ok = PeerConnection.set_local_description(pc, offer)
244245

@@ -247,12 +248,13 @@ defmodule ExWebRTC.PeerConnectionTest do
247248

248249
assert desc != nil
249250

250-
desc_cands =
251-
desc.sdp
252-
|> String.split("\r\n")
253-
|> Enum.filter(&String.starts_with?(&1, "a=candidate:"))
251+
sdp = ExSDP.parse!(desc.sdp)
252+
[audio_mline, video_mline] = sdp.media
253+
"candidate:" <> candidate = cand.candidate
254254

255-
assert ("a=" <> cand.candidate) in desc_cands
255+
assert {"candidate", candidate} in ExSDP.get_attributes(audio_mline, "candidate")
256+
# candidates should only be present in the first m-line
257+
assert [] == ExSDP.get_attributes(video_mline, "candidate")
256258
end
257259
end
258260

0 commit comments

Comments
 (0)