-
Notifications
You must be signed in to change notification settings - Fork 76
/
sdp_test.go
34 lines (30 loc) · 932 Bytes
/
sdp_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package webrtc
import (
. "github.com/smartystreets/goconvey/convey"
"testing"
)
func TestSessionDescription(t *testing.T) {
Convey("SessionDescription", t, func() {
Convey("Serialize and Deserialize", func() {
expected := `{"type":"answer","sdp":"fake"}`
r := DeserializeSessionDescription(expected)
So(r, ShouldNotBeNil)
So(r.Type, ShouldEqual, "answer")
So(r.Sdp, ShouldEqual, "fake")
s := r.Serialize()
So(s, ShouldEqual, expected)
r = DeserializeSessionDescription(`invalid json{{`)
So(r, ShouldBeNil)
r = DeserializeSessionDescription(`{"sdp":"fake"}`)
So(r, ShouldBeNil)
r = DeserializeSessionDescription(`{"type":"answer"}`)
So(r, ShouldBeNil)
Convey("Roundtrip", func() {
sdp := SessionDescription{"pranswer", "not real"}
r = DeserializeSessionDescription(sdp.Serialize())
So(r.Type, ShouldEqual, sdp.Type)
So(r.Sdp, ShouldEqual, sdp.Sdp)
})
})
})
}