relevance / blue-ridge

Framework for JavaScript Testing (currently a Rails Plugin)
http://groups.google.com/group/blueridgejs
MIT License
480 stars 40 forks source link

Problems with jQuery "val()" function #1

Closed karnowski closed 15 years ago

karnowski commented 15 years ago

Per Britt Crawford:

I'm having some problems getting the val function to work properly with select boxes. val() always seems to return null and val('value') properly sets the selected option but val() still returns null. It looks like the selectedIndex is not updated. I don't know whether this has to do with Blue Ridge or env.js or what.

karnowski commented 15 years ago

Britt, the last version of env.js I updated to last week explicitly fixed this bug. I've tested before and after saw the following work:

describe("training wheels", function(){
  it("handles select boxes properly", function(){
    expect($("#some-select").val()).to(equal, "2");
    expect($("#some-select :selected").val()).to(equal, "2");
    expect($("#some-select :selected").text()).to(equal, "Two");
  });
});

against the following HTML fixture:

<select id="some-select">
  <option value="1">One</option>
  <option value="2" selected="selected">Two</option>
  <option value="3">Three</option>
</select>