Sha256: ffa43000ccce199b86b521a1e4f262277672881cdf4b236b394f31494b0a1681
Contents?: true
Size: 1.43 KB
Versions: 1
Compression:
Stored size: 1.43 KB
Contents
describe 'The Checkbox Array Field', -> beforeEach -> @model = new Backbone.Model(item_ids: ["1"]) collection = new Luca.Collection @formView = new Luca.components.FormView components:[ ctype: "checkbox_array" name: 'item_ids' collection: collection ] @formView.render() @formView.loadModel(@model) collection.reset([ id: "1", name: "Item1" , id: "2", name: "Item2" , id: "3", name: "Item3" ]) @field = @formView.getFields()[0] it "should create a checkbox array field", -> expect(@formView.currentModel()).toEqual(@model) expect(@field.selectedItems).toEqual(["1"]) it "should render the list of checkboxes", -> expect(@field.$el.html()).toContain("Item1") expect(@field.$el.html()).toContain("Item2") expect(@field.$el.html()).toContain("Item3") it "should check off each checkbox in the collection that is selected", -> expect(@field.$el.find("input[value='1']")[0].checked).toBeTruthy() expect(@field.$el.find("input[value='2']")[0].checked).toBeFalsy() expect(@field.$el.find("input[value='3']")[0].checked).toBeFalsy() it "should update the form model's attribute to be an array of selected items on click", -> checkbox = $(@field.$el.find("input[value='2']")[0]) checkbox.prop("checked", true) checkbox.click() expect(@field.getModel().get('item_ids')).toEqual(["1", "2"])
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
luca-0.9.0 | spec/components/fields/checkbox_array_spec.coffee |