Skip to content
This repository has been archived by the owner on Jun 26, 2022. It is now read-only.

Commit

Permalink
Fix failing test. Closes gh-21.
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmillr committed Oct 23, 2013
1 parent 1ecfd31 commit 6199aab
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
4 changes: 2 additions & 2 deletions lib/collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ _.extend(Collection.prototype, Events, {

// The default model for a collection is just a **Backbone.Model**.
// This should be overridden in most cases.
model: Model,
model: typeof Model === 'undefined' ? null : Model,

This comment has been minimized.

Copy link
@akre54

akre54 Oct 23, 2013

Contributor

when would you want this?

This comment has been minimized.

Copy link
@paulmillr

paulmillr Oct 23, 2013

Author Owner

custom build without model


// Initialize is an empty function by default. Override it with your own
// initialization logic.
Expand Down Expand Up @@ -325,7 +325,7 @@ _.extend(Collection.prototype, Events, {
// Prepare a hash of attributes (or other model) to be added to this
// collection.
_prepareModel: function(attrs, options) {
if (attrs instanceof Model) {
if (attrs instanceof Collection.prototype.model) {
if (!attrs.collection) attrs.collection = this;
return attrs;
}
Expand Down
13 changes: 10 additions & 3 deletions test/view-no-jq.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,19 @@
});


test("delegateEvents ignore undefined methods", 0, function() {
// test("delegateEvents ignore undefined methods", 0, function() {
// var view = new Backbone.View({el: document.createElement('p')});
// view.delegateEvents({'click': 'undefinedMethod'});
// view.el.click();
// });
test("delegateEvents DOES NOT ignore undefined methods", 1, function(assert) {
var view = new Backbone.View({el: document.createElement('p')});
view.delegateEvents({'click': 'undefinedMethod'});
view.el.click();
assert.throws(function() {
view.delegateEvents({'click': 'undefinedMethod'})
});
});


test("undelegateEvents", 6, function() {
var counter1 = 0, counter2 = 0;
var el = document.createElement('p');
Expand Down
12 changes: 9 additions & 3 deletions test/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,16 @@
});


test("delegateEvents ignore undefined methods", 0, function() {
// test("delegateEvents ignore undefined methods", 0, function() {
// var view = new Backbone.View({el: '<p></p>'});
// view.delegateEvents({'click': 'undefinedMethod'});
// view.$el.trigger('click');
// });
test("delegateEvents DOES NOT ignore undefined methods", 1, function(assert) {
var view = new Backbone.View({el: '<p></p>'});
view.delegateEvents({'click': 'undefinedMethod'});
view.$el.trigger('click');
assert.throws(function() {

This comment has been minimized.

Copy link
@akre54

akre54 Oct 23, 2013

Contributor

👍

view.delegateEvents({'click': 'undefinedMethod'})
});
});

test("undelegateEvents", 6, function() {
Expand Down

0 comments on commit 6199aab

Please sign in to comment.