add helper method to cleanup isNew test

This commit is contained in:
Matt Smith
2011-03-03 17:40:26 -05:00
parent 4595b48ffb
commit 12e9d95b45

View File

@@ -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() {