forked from mxriverlynn/backbone.modelbinding
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
spec to show failing when input has no type specified
- Loading branch information
Derick Bailey
committed
Aug 27, 2011
1 parent
15e9587
commit 20a2d9d
Showing
2 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
describe("textbox convention bindings", function(){ | ||
beforeEach(function(){ | ||
this.model = new AModel({ | ||
name: "Ashelia Bailey", | ||
noType: 'there is no type' | ||
}); | ||
this.view = new AView({model: this.model}); | ||
this.view.render(); | ||
}); | ||
|
||
describe("text element binding", function(){ | ||
it("bind view changes to the model's field, by convention of id", function(){ | ||
var el = this.view.$("#name"); | ||
el.val("Derick Bailey"); | ||
el.trigger('change'); | ||
|
||
expect(this.model.get('name')).toEqual("Derick Bailey"); | ||
}); | ||
|
||
it("bind model field changes to the form input, by convention of id", function(){ | ||
this.model.set({name: "Ian Bailey"}); | ||
var el = this.view.$("#name"); | ||
expect(el.val()).toEqual("Ian Bailey"); | ||
}); | ||
|
||
it("binds the model's value to the form field on render", function(){ | ||
var el = this.view.$("#name"); | ||
expect(el.val()).toEqual("Ashelia Bailey"); | ||
}); | ||
}); | ||
|
||
describe("input with no type specified, binding", function(){ | ||
beforeEach(function(){ | ||
this.el = this.view.$("#noType"); | ||
}); | ||
|
||
it("bind view changes to the model's field, by convention of id", function(){ | ||
this.el.val("something changed"); | ||
this.el.trigger('change'); | ||
|
||
expect(this.model.get('noType')).toEqual("something changed"); | ||
}); | ||
|
||
it("bind model field changes to the form input, by convention of id", function(){ | ||
this.model.set({noType: "Ian Bailey"}); | ||
expect(this.el.val()).toEqual("Ian Bailey"); | ||
}); | ||
|
||
it("binds the model's value to the form field on render", function(){ | ||
expect(this.el.val()).toEqual("there is no type"); | ||
}); | ||
}); | ||
}); |