initial page load", -> expect(_.pluck(window.items[1], 'value')).toEqual(["1", "2"]) expect(_.pluck(window.items[2], 'value')).toEqual(["3"]) it "removes the original options after extracting", -> expect($("#item_list option").length).toEqual(0) it "adds the proper items on change", -> $("#order_category_id").val("1") $("#order_category_id").change() expect(_.pluck($("#item_list option"), 'value')).toEqual(["1", "2"])
describe "with category and item list", -> beforeEach -> @result = new DualSelect() @result.dom = new TestDom() @result.initialize() ! it "extracts items from the initial page load", -> expect(@result.items[1]).toEqual(["1", "2"]) expect(@result.items[2]).toEqual(["3"]) Stub For Tests
original options after extracting", -> expect($("#item_list option").length).toEqual(0) ! it "adds the proper items on change", -> @result.dom.categoryList().val("1") @result.dom.categoryList().change() expect(_.pluck(@result.dom.itemList().children(), 'value')).toEqual(["1", "2"]) Stub For Tests