-
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.
Added tests to find collisons with backbone model/collection existing…
… methods. Fixed those that were found.
- Loading branch information
Showing
8 changed files
with
234 additions
and
151 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,71 @@ | ||
/* global test, module, ok */ | ||
(function (Backbone, _, querybuilder) { | ||
"use strict"; | ||
|
||
var user, | ||
users, | ||
User, | ||
UserCollection, | ||
bbMixin = querybuilder.getMixin(), | ||
expectedCollisions = ['sync']; | ||
|
||
module("Backbone Mixin", { | ||
setup: function() { | ||
User = Backbone.Model.extend({ | ||
urlRoot: '/api/user' | ||
}); | ||
|
||
UserCollection = Backbone.Collection.extend({ | ||
model: User, | ||
url: '/api/user' | ||
}); | ||
} | ||
}); | ||
|
||
test("Backbone Model: unexpected method collisions", _.keys(bbMixin).length - expectedCollisions.length, function () { | ||
var prop; | ||
user = new User(); | ||
|
||
_.indexOf(expectedCollisions, prop); | ||
|
||
for (prop in bbMixin) { | ||
if (_.indexOf(expectedCollisions, prop) !== -1) { | ||
continue; | ||
} | ||
|
||
ok(typeof user[prop] === 'undefined', 'Backbone.Model already has method ' + prop); | ||
} | ||
}); | ||
|
||
test("Backbone Model: expected method collisions", expectedCollisions.length, function () { | ||
var i = 0; | ||
user = new User(); | ||
|
||
for (; i < expectedCollisions.length; i++) { | ||
ok(expectedCollisions[i] !== 'undefined', 'Backbone.Model does not have method ' + expectedCollisions[i]); | ||
} | ||
}); | ||
|
||
test("Backbone Collection: unexpected method collisions", _.keys(bbMixin).length - expectedCollisions.length, function () { | ||
var prop; | ||
users = new UserCollection(); | ||
|
||
for (prop in bbMixin) { | ||
if (_.indexOf(expectedCollisions, prop) !== -1) { | ||
continue; | ||
} | ||
|
||
ok(typeof users[prop] === 'undefined', 'Backbone.Collection already has method ' + prop); | ||
} | ||
}); | ||
|
||
test("Backbone Collection: expected method collisions", expectedCollisions.length, function () { | ||
var i = 0; | ||
users = new UserCollection(); | ||
|
||
for (; i < expectedCollisions.length; i++) { | ||
ok(expectedCollisions[i] !== 'undefined', 'Backbone.Model does not have method ' + expectedCollisions[i]); | ||
} | ||
}); | ||
|
||
})(window.Backbone, window._, window.querybuilder); |
Oops, something went wrong.