webrtc/api_test.go
Alex Browne 34e5a89f71 Add tests for WASM bindings
The tests are run in a Node.js environment, and this does not include
any browser tests. This requires the wrtc package from npm as well as a
shim which adds portions of the WebRTC API to the global scope.

Some tests introduced here can be combined when differences between the
Go API and the WASM bindings are addressed and as missing features are
added to the WASM bindings.

We can and should add more tests in the future to improve test coverage.
This should be considered the minimum number of tests reuqired to ensure
basic functionality is working.
2019-03-15 15:17:51 -07:00

40 lines
635 B
Go

// +build !js
package webrtc
import (
"testing"
)
func TestNewAPI(t *testing.T) {
api := NewAPI()
if api.settingEngine == nil {
t.Error("Failed to init settings engine")
}
if api.mediaEngine == nil {
t.Error("Failed to init media engine")
}
}
func TestNewAPI_Options(t *testing.T) {
s := SettingEngine{}
s.DetachDataChannels()
m := MediaEngine{}
m.RegisterDefaultCodecs()
api := NewAPI(
WithSettingEngine(s),
WithMediaEngine(m),
)
if !api.settingEngine.detach.DataChannels {
t.Error("Failed to set settings engine")
}
if len(api.mediaEngine.codecs) == 0 {
t.Error("Failed to set media engine")
}
}