forked from sclevine/agouti
-
Notifications
You must be signed in to change notification settings - Fork 0
/
capabilities_test.go
47 lines (42 loc) · 1.23 KB
/
capabilities_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
35
36
37
38
39
40
41
42
43
44
45
46
47
package agouti_test
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
. "github.com/sclevine/agouti"
)
var _ = Describe("Capabilities", func() {
var capabilities Capabilities
BeforeEach(func() {
capabilities = NewCapabilities("firstEnabled", "secondEnabled")
})
It("should successfully encode all provided options into JSON", func() {
capabilities.Browser("some-browser").Version("v100").Platform("some-os")
capabilities.With("withEnabled").Without("withoutDisabled")
capabilities.Proxy(ProxyConfig{
ProxyType: "manual",
HTTPProxy: "some-http-proxy",
SSLProxy: "some-http-proxy",
})
Expect(capabilities.JSON()).To(MatchJSON(`{
"browserName": "some-browser",
"version": "v100",
"platform": "some-os",
"withEnabled": true,
"withoutDisabled": false,
"firstEnabled": true,
"secondEnabled": true,
"proxy": {
"proxyType": "manual",
"httpProxy": "some-http-proxy",
"sslProxy": "some-http-proxy"
}
}`))
})
Context("when the provided options cannot be converted to JSON", func() {
It("should return an error", func() {
capabilities["some-feature"] = func() {}
_, err := capabilities.JSON()
Expect(err).To(MatchError("json: unsupported type: func()"))
})
})
})