mirror of
https://github.com/jashkenas/backbone.git
synced 2026-04-08 03:00:26 -04:00
add helper method to cleanup isNew test
This commit is contained in:
@@ -12,6 +12,10 @@ $(document).ready(function() {
|
||||
lastRequest = _.toArray(arguments);
|
||||
};
|
||||
|
||||
var model_with = function(attributes){
|
||||
return new Backbone.Model(attributes);
|
||||
}
|
||||
|
||||
var attrs = {
|
||||
id : '1-the-tempest',
|
||||
title : "The Tempest",
|
||||
@@ -92,12 +96,9 @@ $(document).ready(function() {
|
||||
});
|
||||
|
||||
test("Model: isNew", function() {
|
||||
a = new Backbone.Model({ });
|
||||
ok(a.isNew(), "is true when there is no id");
|
||||
a = new Backbone.Model({ 'id': 2 });
|
||||
ok(!a.isNew(), "is false for a positive integer");
|
||||
a = new Backbone.Model({ 'id': -5 });
|
||||
ok(!a.isNew(), "is false for a negative integer");
|
||||
ok( model_with({ }).isNew(), "is true when there is no id");
|
||||
ok(!model_with({ 'id': 2 }).isNew(), "is false for a positive integer");
|
||||
ok(!model_with({ 'id': -5 }).isNew(), "is false for a negative integer");
|
||||
});
|
||||
|
||||
test("Model: get", function() {
|
||||
|
||||
Reference in New Issue
Block a user