Skip to content

Commit 7273875

Browse files
committed
issue#58 add more specs to cover edge cases
1 parent 778d270 commit 7273875

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

spec/node_spec.rb

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,33 @@ module Ferrum
118118
end
119119

120120
it "picks option in select by match string argument" do
121-
expect(browser.at_xpath("//*[@id='form_title']").select("Miss").value).to eq("Miss")
121+
expect(browser.at_xpath("//*[@id='form_title']").select("Miss").selected).to eq(["Miss"])
122+
end
123+
124+
shared_examples "clears selected options with no exception" do |options|
125+
it "clears selected options with no exception" do
126+
expect(browser.at_xpath("//*[@id='form_title']").selected).to eq(["Mrs"])
127+
expect(browser.at_xpath("//*[@id='form_title']").select(options).selected).to eq([])
128+
end
129+
end
130+
131+
context "when option with provided text does not exist" do
132+
include_examples "clears selected options with no exception", "Gotcha"
133+
end
134+
135+
context "when provided empty array" do
136+
include_examples "clears selected options with no exception", []
137+
end
138+
139+
context "when provided empty string" do
140+
include_examples "clears selected options with no exception", ""
141+
end
142+
143+
context "when one of option with provided texts does not exist" do
144+
it "picks only existed options with no exception" do
145+
expect(browser.at_xpath("//*[@id='form_title']").selected).to eq(["Mrs"])
146+
expect(browser.at_xpath("//*[@id='form_title']").select(%w[Mrs SQL]).selected).to eq(["Mrs"])
147+
end
122148
end
123149

124150
context "when select has multiple property" do

0 commit comments

Comments
 (0)