Skip to content
This repository has been archived by the owner on Dec 16, 2023. It is now read-only.

Commit

Permalink
Merge pull request #537 from graffic/master
Browse files Browse the repository at this point in the history
 Use a selector in unselectOption like selectOption does.
  • Loading branch information
assaf committed Jun 23, 2013
2 parents eeaffb2 + 9b35599 commit 7590588
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/zombie/browser.coffee
Expand Up @@ -817,10 +817,11 @@ class Browser extends EventEmitter
#
# Unselects an option.
#
# option - option to unselect
# selector - selector or option to unselect
#
# Without callback, returns this.
unselectOption: (option)->
unselectOption: (selector)->
option = @query(selector)
if option && option.getAttribute("selected")
select = @xpath("./ancestor::select", option).iterateNext()
unless select.multiple
Expand Down
12 changes: 12 additions & 0 deletions test/forms_test.coffee
Expand Up @@ -607,6 +607,18 @@ describe "Forms", ->
selected = (!!option.getAttribute("selected") for option in browser.querySelector("#field-hobbies").options)
assert.deepEqual selected, [true, false, false]

describe "unselect name using option selector", ->
before (done)->
browser.visit("/forms/form")
.then ->
browser.selectOption("#hobbies-messy")
browser.unselectOption("#hobbies-messy")
return
.then(done, done)

it "should unselect items", ->
assert !browser.query("#hobbies-messy").selected

describe "with callback", ->
before (done)->
browser.visit "/forms/form", ->
Expand Down

0 comments on commit 7590588

Please sign in to comment.