-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoptions_test.go
105 lines (94 loc) · 3.24 KB
/
options_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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
package agouti_test
import (
"net/http"
"time"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
. "github.com/sclevine/agouti"
. "github.com/andress134/agouti/internal/matchers"
)
var _ = Describe("Options", func() {
Describe("#Browser", func() {
It("should return an Option that sets a browser name", func() {
config := NewTestConfig()
Browser("some browser")(config)
Expect(config.BrowserName).To(Equal("some browser"))
})
})
Describe("#Timeout", func() {
It("should return an Option that sets a timeout as a time.Duration", func() {
config := NewTestConfig()
Timeout(5)(config)
Expect(config.Timeout).To(Equal(5 * time.Second))
})
})
Describe("#Desired", func() {
It("should return an Option that sets desired capabilities", func() {
config := NewTestConfig()
capabilities := NewCapabilities("some feature")
Desired(capabilities)(config)
Expect(config.DesiredCapabilities).To(Equal(capabilities))
})
})
Describe("#RejectInvalidSSL", func() {
It("should return an Option that rejects invalid SSL certificates", func() {
config := NewTestConfig()
Expect(config.RejectInvalidSSL).To(BeFalse())
RejectInvalidSSL(config)
Expect(config.RejectInvalidSSL).To(BeTrue())
})
})
Describe("#Debug", func() {
It("should return an Option that debugs a WebDriver", func() {
config := NewTestConfig()
Expect(config.Debug).To(BeFalse())
Debug(config)
Expect(config.Debug).To(BeTrue())
})
})
Describe("#HTTPClient", func() {
It("should return an Option that sets a *http.Client", func() {
config := NewTestConfig()
client := &http.Client{}
HTTPClient(client)(config)
Expect(config.HTTPClient).To(ExactlyEqual(client))
})
})
Describe("#ChromeOptions", func() {
It("should return an Option with ChromeOptions set", func() {
config := NewTestConfig()
ChromeOptions("args", []string{"v1", "v2"})(config)
Expect(config.ChromeOptions["args"]).To(Equal([]string{"v1", "v2"}))
ChromeOptions("other", "value")(config)
Expect(config.ChromeOptions["args"]).To(Equal([]string{"v1", "v2"}))
Expect(config.ChromeOptions["other"]).To(Equal("value"))
})
})
Describe("#Merge", func() {
It("should apply any provided options to an existing config", func() {
config := NewTestConfig()
Browser("some browser")(config)
newConfig := config.Merge([]Option{Timeout(5), Debug})
Expect(newConfig.BrowserName).To(Equal("some browser"))
Expect(newConfig.Timeout).To(Equal(5 * time.Second))
Expect(newConfig.Debug).To(BeTrue())
})
})
Describe("#Capabilities", func() {
It("should return a merged copy of the desired capabilities", func() {
config := NewTestConfig()
capabilities := NewCapabilities().Browser("some browser")
Desired(capabilities)(config)
Expect(config.Capabilities()["browserName"]).To(Equal("some browser"))
Expect(config.Capabilities()["acceptSslCerts"]).To(BeTrue())
Browser("some other browser")(config)
RejectInvalidSSL(config)
Expect(config.Capabilities()["browserName"]).To(Equal("some other browser"))
Expect(config.Capabilities()["acceptSslCerts"]).To(BeFalse())
ChromeOptions("args", "someArg")(config)
Expect(config.Capabilities()["chromeOptions"]).To(
Equal(map[string]interface{}{"args": "someArg"}),
)
})
})
})