VimUnDo.2}lRtRvIg\`q1%var GModel = require("models").Model; mmmmM@$_ vMPj  "use strict";5_  vMPl   5_  vMP {  5_  vMP  module("Backbone.Model");5_  vMP 5_  vMP ( // Variable to catch the last request.5_  vMP  window.lastRequest = null;5_   vMP 5_  vMP & window.originalSync = Backbone.sync;5_  vMP 5_  tvMP uyk! // Stub out Backbone.request... Backbone.sync = function() {' lastRequest = _.toArray(arguments); }; var attrs = { id : '1-the-tempest', title : "The Tempest", author : "Bill Shakespeare", length : 123 };& var proxy = Backbone.Model.extend(); var doc = new proxy(attrs);* var klass = Backbone.Collection.extend({. url : function() { return '/collection'; } }); var collection = new klass(); collection.add(doc);( test("Model: initialize", function() {' var Model = Backbone.Model.extend({ initialize: function() { this.one = 1;, equals(this.collection, collection); } });8 var model = new Model({}, {collection: collection}); equals(model.one, 1);) equals(model.collection, collection); });D test("Model: initialize with attributes and options", function() {' var Model = Backbone.Model.extend({1 initialize: function(attributes, options) { this.one = options.one; } });( var model = new Model({}, {one: 1}); equals(model.one, 1); });! test("Model: url", function() {3 equals(doc.url(), '/collection/1-the-tempest');( doc.collection.url = '/collection/';3 equals(doc.url(), '/collection/1-the-tempest'); doc.collection = null; var failed = false; try { doc.url(); } catch (e) { failed = true; } equals(failed, true); doc.collection = collection; });F test("Model: url when using urlRoot, and uri encoding", function() {' var Model = Backbone.Model.extend({ urlRoot: '/collection' }); var model = new Model();' equals(model.url(), '/collection'); model.set({id: '+1+'});/ equals(model.url(), '/collection/%2B1%2B'); });# test("Model: clone", function() {, attrs = { 'foo': 1, 'bar': 2, 'baz': 3};" a = new Backbone.Model(attrs); b = a.clone(); equals(a.get('foo'), 1); equals(a.get('bar'), 2); equals(a.get('baz'), 3);O equals(b.get('foo'), a.get('foo'), "Foo should be the same on the clone.");O equals(b.get('bar'), a.get('bar'), "Bar should be the same on the clone.");O equals(b.get('baz'), a.get('baz'), "Baz should be the same on the clone."); a.set({foo : 100}); equals(a.get('foo'), 100);V equals(b.get('foo'), 1, "Changing a parent attribute does not change the clone."); });# test("Model: isNew", function() {, attrs = { 'foo': 1, 'bar': 2, 'baz': 3};" a = new Backbone.Model(attrs);& ok(a.isNew(), "it should be new");7 attrs = { 'foo': 1, 'bar': 2, 'baz': 3, 'id': -5 };C ok(a.isNew(), "any defined ID is legal, negative or positive"); });! test("Model: get", function() {, equals(doc.get('title'), 'The Tempest');2 equals(doc.get('author'), 'Bill Shakespeare'); });$ test("Model: escape", function() {/ equals(doc.escape('title'), 'The Tempest');& doc.set({audience: 'Bill & Bob'});5 equals(doc.escape('audience'), 'Bill & Bob');& doc.set({audience: 'Tim > Joan'});4 equals(doc.escape('audience'), 'Tim > Joan'); doc.set({audience: 10101});, equals(doc.escape('audience'), '10101'); doc.unset('audience');' equals(doc.escape('audience'), ''); });! test("Model: has", function() { attrs = {};" a = new Backbone.Model(attrs);! equals(a.has("name"), false);? _([true, "Truth!", 1, false, '', 0]).each(function(value) { a.set({'name': value});" equals(a.has("name"), true); }); a.unset('name');! equals(a.has('name'), false);/ _([null, undefined]).each(function(value) { a.set({'name': value});# equals(a.has("name"), false); }); });+ test("Model: set and unset", function() {/ attrs = {id: 'id', foo: 1, bar: 2, baz: 3};" a = new Backbone.Model(attrs); var changeCount = 0;; a.bind("change:foo", function() { changeCount += 1; }); a.set({'foo': 2});5 ok(a.get('foo')== 2, "Foo should have changed.");B ok(changeCount == 1, "Change count should have incremented.");T a.set({'foo': 2}); // set with value that is not new shouldn't fire change eventA ok(a.get('foo')== 2, "Foo should NOT have changed, still 2");F ok(changeCount == 1, "Change count should NOT have incremented."); a.unset('foo');7 ok(a.get('foo')== null, "Foo should have changed");L ok(changeCount == 2, "Change count should have incremented for unset."); a.unset('id');O equals(a.id, undefined, "Unsetting the id should remove the id property."); });- test("Model: multiple unsets", function() { var i = 0;% var counter = function(){ i++; };+ var model = new Backbone.Model({a: 1});$ model.bind("change:a", counter); model.set({a: 2}); model.unset('a'); model.unset('a');I equals(i, 2, 'Unset does not fire an event for missing attributes.'); });? test("Model: using a non-default id attribute.", function() {B var MongoModel = Backbone.Model.extend({idAttribute : '_id'});I var model = new MongoModel({id: 'eye-dee', _id: 25, title: 'Model'});' equals(model.get('id'), 'eye-dee'); equals(model.id, 25); model.unset('_id'); equals(model.id, undefined); });1 test("Model: set an empty string", function() {5 var model = new Backbone.Model({name : "Model"}); model.set({name : ''});" equals(model.get('name'), ''); });# test("Model: clear", function() { var changed;5 var model = new Backbone.Model({name : "Model"});= model.bind("change:name", function(){ changed = true; }); model.clear(); equals(changed, true);) equals(model.get('name'), undefined); });& test("Model: defaults", function() {+ var Defaulted = Backbone.Model.extend({ defaults: { "one": 1, "two": 2 } });+ var model = new Defaulted({two: null}); equals(model.get('one'), 1);# equals(model.get('two'), null);' Defaulted = Backbone.Model.extend({ defaults: function() { return { "one": 3, "two": 4 }; } });+ var model = new Defaulted({two: null}); equals(model.get('one'), 3);# equals(model.get('two'), null); });a test("Model: change, hasChanged, changedAttributes, previous, previousAttributes", function() {= var model = new Backbone.Model({name : "Tim", age : 10});- equals(model.changedAttributes(), false);% model.bind('change', function() {3 ok(model.hasChanged('name'), 'name changed');2 ok(!model.hasChanged('age'), 'age did not');n ok(_.isEqual(model.changedAttributes(), {name : 'Rob'}), 'changedAttributes returns the changed attrs');, equals(model.previous('name'), 'Tim');k ok(_.isEqual(model.previousAttributes(), {name : "Tim", age : 10}), 'previousAttributes is correct'); });/ model.set({name : 'Rob'}, {silent : true});% equals(model.hasChanged(), true);+ equals(model.hasChanged('name'), true); model.change();% equals(model.get('name'), 'Rob'); });1 test("Model: change with options", function() { var value;2 var model = new Backbone.Model({name: 'Rob'});3 model.bind('change', function(model, options) {1 value = options.prefix + model.get('name'); });- model.set({name: 'Bob'}, {silent: true});# model.change({prefix: 'Mr. '}); equals(value, 'Mr. Bob');/ model.set({name: 'Sue'}, {prefix: 'Ms. '}); equals(value, 'Ms. Sue'); });6 test("Model: change after initialize", function () { var changed = 0;$ var attrs = {id: 1, label: 'c'};( var obj = new Backbone.Model(attrs);5 obj.bind('change', function() { changed += 1; }); obj.set(attrs); equals(changed, 0); });7 test("Model: save within change event", function () {N var model = new Backbone.Model({firstName : "Taylor", lastName: "Swift"});& model.bind('change', function () { model.save();+ ok(_.isEqual(lastRequest[1], model)); });# model.set({lastName: 'Hicks'}); });" test("Model: save", function() {" doc.save({title : "Henry V"});% equals(lastRequest[0], 'update');' ok(_.isEqual(lastRequest[1], doc)); });# test("Model: fetch", function() { doc.fetch(); ok(lastRequest[0], 'read');' ok(_.isEqual(lastRequest[1], doc)); });% test("Model: destroy", function() { doc.destroy();% equals(lastRequest[0], 'delete');' ok(_.isEqual(lastRequest[1], doc)); });& test("Model: validate", function() { var lastError;% var model = new Backbone.Model();& model.validate = function(attrs) {; if (attrs.admin) return "Can't change admin status."; };0 model.bind('error', function(model, error) { lastError = error; });% var result = model.set({a: 100}); equals(result, model); equals(model.get('a'), 100);! equals(lastError, undefined);6 result = model.set({admin: true}, {silent: true});! equals(lastError, undefined);% equals(model.get('admin'), true);. result = model.set({a: 200, admin: true}); equals(result, false); equals(model.get('a'), 100);4 equals(lastError, "Can't change admin status."); });9 test("Model: validate on unset and clear", function() { var error;2 var model = new Backbone.Model({name: "One"});& model.validate = function(attrs) { if ("name" in attrs) { if (!attrs.name) { error = true; return "No thanks."; } } }; model.set({name: "Two"});% equals(model.get('name'), 'Two'); equals(error, undefined); model.unset('name'); equals(error, true);% equals(model.get('name'), 'Two'); model.clear();% equals(model.get('name'), 'Two'); delete model.validate; model.clear();) equals(model.get('name'), undefined); });: test("Model: validate with error callback", function() { var lastError, boundError;% var model = new Backbone.Model();& model.validate = function(attrs) {; if (attrs.admin) return "Can't change admin status."; };+ var callback = function(model, error) { lastError = error; };0 model.bind('error', function(model, error) { boundError = true; });8 var result = model.set({a: 100}, {error: callback}); equals(result, model); equals(model.get('a'), 100);! equals(lastError, undefined);" equals(boundError, undefined);A result = model.set({a: 200, admin: true}, {error: callback}); equals(result, false); equals(model.get('a'), 100);4 equals(lastError, "Can't change admin status.");" equals(boundError, undefined); });6 test("Model: Inherit class properties", function() {( var Parent = Backbone.Model.extend({& instancePropSame: function() {},% instancePropDiff: function() {} }, { classProp: function() {} }); var Child = Parent.extend({% instancePropDiff: function() {} }); var adult = new Parent; var kid = new Child;. equals(Child.classProp, Parent.classProp);) notEqual(Child.classProp, undefined);9 equals(kid.instancePropSame, adult.instancePropSame);. notEqual(kid.instancePropSame, undefined);R notEqual(Child.prototype.instancePropDiff, Parent.prototype.instancePropDiff);: notEqual(Child.prototype.instancePropDiff, undefined); });5_  tvMQl!y&test("Model: initialize", function() {5_   tvMQo!y!"Model: initialize", function() {5_   tvMQ!y.exports["test Model: initialize", function() {5_ - tvMQ!y0exports["test Model: initialize"] = function() {5_* tvMQ)+y});5_, tvMQ35y});+-yBtest("Model: initialize with attributes and options", function() {5_6 tvMRBDy});57ytest("Model: url", function() {5_E tvMRLNy});DFyDtest("Model: url when using urlRoot, and uri encoding", function() {5_O tvMR[]y});NPy!test("Model: clone", function() {5_^ tvMR$cey});]_y!test("Model: isNew", function() {5_f tvMR*hjy});egytest("Model: get", function() {5_k tvMR1tvy});jly"test("Model: escape", function() {5_w tvMR7y});vxytest("Model: has", function() {5_ tvMRBy});y)test("Model: set and unset", function() {5_ tvMRIy});y+test("Model: multiple unsets", function() {5_ tvMRQy});y=test("Model: using a non-default id attribute.", function() {5_ tvMRdy});y/test("Model: set an empty string", function() {5_ tvMRiy});y!test("Model: clear", function() {5_ tvMRpy});y$test("Model: defaults", function() {5_  tvMRwy});y_test("Model: change, hasChanged, changedAttributes, previous, previousAttributes", function() {5_!  tvMRy});y/test("Model: change with options", function() {5_ "! tvMRy});y4test("Model: change after initialize", function () {5_!#" tvMRy});y5test("Model: save within change event", function () {5_"$# tvMR y});y test("Model: save", function() {5_#%$  tvMRy});  y!test("Model: fetch", function() {5_$&% tvMRy});y#test("Model: destroy", function() {5_%'& tvMR*,y});y$test("Model: validate", function() {5_&('- tvMRBDy});,.y7test("Model: validate on unset and clear", function() {5_')(E tvMRZ\y});DFy8test("Model: validate with error callback", function() {5_(*)] tvMRrty});\^y4test("Model: Inherit class properties", function() {5_)+* !!vMS&]_& var Parent = Backbone.Model.extend({FH# var model = new Backbone.Model();.00 var model = new Backbone.Model({name: "One"});# var model = new Backbone.Model();L var model = new Backbone.Model({firstName : "Taylor", lastName: "Swift"});& var obj = new Backbone.Model(attrs);0 var model = new Backbone.Model({name: 'Rob'});; var model = new Backbone.Model({name : "Tim", age : 10});% Defaulted = Backbone.Model.extend({) var Defaulted = Backbone.Model.extend({3 var model = new Backbone.Model({name : "Model"});3 var model = new Backbone.Model({name : "Model"});@ var MongoModel = Backbone.Model.extend({idAttribute : '_id'});) var model = new Backbone.Model({a: 1}); a = new Backbone.Model(attrs);xz a = new Backbone.Model(attrs);_a a = new Backbone.Model(attrs);PR a = new Backbone.Model(attrs);EG% var Model = Backbone.Model.extend({,.% var Model = Backbone.Model.extend({ "% var Model = Backbone.Model.extend({(var klass = Backbone.Collection.extend({$var proxy = Backbone.Model.extend(); Backbone.sync = function() { // Stub out Backbone.request...5_*,+!!vMS/ var Moder = require z y5_+-, ##vMS6 {var Moder = require()5_,.- ##vMS6 {var Moder = require("")5_-/. ##vMS8 {var Moder = require("model")5_.0/ "##vMS: {"var Moder = require("model").Model5_/10 ##vMS< {#var Moder = require("model").Model;5_021&##vMS`oq7 equals(kid.instancePropSame, adult.instancePropSame);ln, equals(Child.classProp, Parent.classProp);[] equals(boundError, undefined);Z\2 equals(lastError, "Can't change admin status.");Y[ equals(model.get('a'), 100);XZ equals(result, false);VX equals(boundError, undefined);UW equals(lastError, undefined);TV equals(model.get('a'), 100);SU equals(result, model);CE' equals(model.get('name'), undefined);@B# equals(model.get('name'), 'Two');>@# equals(model.get('name'), 'Two');=? equals(error, true);;= equals(error, undefined);:<# equals(model.get('name'), 'Two');+-2 equals(lastError, "Can't change admin status.");*, equals(model.get('a'), 100);)+ equals(result, false);')# equals(model.get('admin'), true);&( equals(lastError, undefined);$& equals(lastError, undefined);#% equals(model.get('a'), 100);"$ equals(result, model);# equals(lastRequest[0], 'delete'); # equals(lastRequest[0], 'update'); equals(changed, 0); equals(value, 'Ms. Sue'); equals(value, 'Mr. Bob');# equals(model.get('name'), 'Rob');) equals(model.hasChanged('name'), true);# equals(model.hasChanged(), true);* equals(model.previous('name'), 'Tim');+ equals(model.changedAttributes(), false);! equals(model.get('two'), null); equals(model.get('one'), 3);! equals(model.get('two'), null); equals(model.get('one'), 1);' equals(model.get('name'), undefined); equals(changed, true); equals(model.get('name'), ''); equals(model.id, undefined); equals(model.id, 25);% equals(model.get('id'), 'eye-dee');G equals(i, 2, 'Unset does not fire an event for missing attributes.');M equals(a.id, undefined, "Unsetting the id should remove the id property.");! equals(a.has("name"), false); equals(a.has('name'), false);~ equals(a.has("name"), true);{} equals(a.has("name"), false);uw% equals(doc.escape('audience'), '');su* equals(doc.escape('audience'), '10101');qs2 equals(doc.escape('audience'), 'Tim > Joan');oq3 equals(doc.escape('audience'), 'Bill & Bob');mo- equals(doc.escape('title'), 'The Tempest');ik0 equals(doc.get('author'), 'Bill Shakespeare');hj* equals(doc.get('title'), 'The Tempest');\^T equals(b.get('foo'), 1, "Changing a parent attribute does not change the clone.");[] equals(a.get('foo'), 100);Y[M equals(b.get('baz'), a.get('baz'), "Baz should be the same on the clone.");XZM equals(b.get('bar'), a.get('bar'), "Bar should be the same on the clone.");WYM equals(b.get('foo'), a.get('foo'), "Foo should be the same on the clone.");VX equals(a.get('baz'), 3);UW equals(a.get('bar'), 2);TV equals(a.get('foo'), 1);MO- equals(model.url(), '/collection/%2B1%2B');KM% equals(model.url(), '/collection');BD equals(failed, true);:<1 equals(doc.url(), '/collection/1-the-tempest');8:1 equals(doc.url(), '/collection/1-the-tempest');46 equals(model.one, 1);*,' equals(model.collection, collection);)+ equals(model.one, 1);%'* equals(this.collection, collection);5_132n##vMStsu8 notEqual(Child.prototype.instancePropDiff, undefined);rtP notEqual(Child.prototype.instancePropDiff, Parent.prototype.instancePropDiff);pr, notEqual(kid.instancePropSame, undefined);mo' notEqual(Child.classProp, undefined);5_243  vMS {sync = function() {5_364  vMS { = function() {5_4756  vMS { function() {5_687 vMS {% lastRequest = _.toArray(arguments);5_798  vMS {5_8:9  vMS function toArray | {5_9;: vMS }function toArray()5_:<; vMS }function toArray(arguments)5_;=< vMS }function toArray()5_<>= vMS }function toArray() {}5_=?> vMS ~function toArray() {5_>@? vMS ~function toArray(arrayLive) {5_?A@ vMS   ~5_@BA vMS 5_ACB vMS /var toArray = Array.prototype.slice.call.bind()5_BDC KvMS Lvar toArray = Function.prototype.call.bind(Array.prototype.slice.call.bind()5_CED AvMS 5_DFEvMS function toArray(arrayLike) {5_EGFvMS  Array.prototype.5_FHGvMS }5_GIHvMS}};5_HJIvMS}function sync() {!lastRequest = toArray(arguments);}# lastRequest = toArray(arguments);5_IKJvMS|3function sync() { lastRequest = toArray(arguments);}|}5_JLK vMS {$var Moder = require("models").Model;5_KMLvMT{var doc = new proxy(attrs);5_LNMvMT|{5_MONvMT}}); } |5_NPO"vMT!#|5_OQP"vMT "$|5_PRQ+vMT_*,}6 var model = new Model({}, {collection: collection});5_QSR+4vMTb*,}7 var model = new Model({}, { collection: collection});5_RTSvMTn}var klass = Collection.extend({5_SUTvMTq/*5_TVUvMT |var collection = new klass();5_UWVvMT!}!|5_VXW NNvM< ~ }5_WYX OOvM< ~var BModel = Model.extend()5_XZY OOvM< ~var BModel = Model.extend({})5_Y[ZPPvM return url + (url.charAt(base.length - 1) == '/' ? '' : '/')5_AvAM=8 return url + (url.[base.length - 1) == '/' ? '' : '/')5_$AvAM=7 return url + (url[base.length - 1) == '/' ? '' : '/')5_'AvAM=7 return url + (url[base.length - 1] == '/' ? '' : '/')5_8AvAM=8 return url + (url[base.length - 1] === '/' ? '' : '/')5_AvAM=9 return url + (url[base.length - 1] === '/' ? '' : '/');5_BAvAM=a return base + (base.charAt(base.length - 1) == '/' ? '' : '/') + encodeURIComponent(this.id);5_AvAM=8 return normalizeURL() + encodeURIComponent(this.id);5_( v M=( return this.isNew() ? base : base + 5_  v M=4 return this.isNew() ? base : normalizeURL(base) 5_ v M=< return normalizeURL(base) + encodeURIComponent(this.id);5_  v M= = normalizeURL(base) + encodeURIComponent(this.id);5_* v M>)+var proxy = Model.extend();*,*,5_+ v M> *,//var doc = new proxy(attrs);5_+ v M>*,var doc = new proxy(attrs);5_* v M> )+var proxy = Model.extend();5_*  v M>? )+var Proxy = Model.extend();5_2 v M>p12/*5_3 v M>q 23*/5_1 v M>02var collection = new Model();5_1 v M>03var collection = new Model({});5_1 v M>13 135_2 v M>13 add: function add()5_2 v M>14 add: function add() {}5_2 v M>245_3 v M>245_2 v M>13 add: function add() {5_3 v M>24 5_3 v M>24 if ()5_3 v M>24 if (model.collection)5_3 v M>24 if (!model.collection)5_3 v M>25, if (!model.collection) model.collection 5_4 v M>35 model.collection 5_K v M>JL& var model = new Model({}, {one: 1});5_K$ v M>JL' var model = new Model({}, { one: 1});5_A v M?@B assert.equal(model.one, 1);5_A v M?@B! assert.equal(model.one, 1, "");5_A7 v M?-@BC assert.equal(model.one, 1, "initalize have set `one` attribute");5_A: v M?0@B= assert.equal(model.one, 1, "initalize have set attribute");5_B+ v M?3AC- assert.equal(model.collection, collection);5_B. v M?SAC1 assert.equal(model.collection, collection, "");5_B- v M?]ADR assert.equal(model.collection, collection, "collection was set by constructor");5_1**v#ME02var collection = new Model({5_1**v#ME02#var collection = new Model.extend({5_1**v#ME02#var Collection = new Model.extend({5_6**v#ME58});68685_"**v#ME% forin: true, eqnull: true */5_"**v#ME6 forin: true, eqnull: true, supernew: true */5_F**v#MEFHFH5_G**v#MEFGreturn5_F**v#MEFHFH5_**v#ME5_ **v#MF'  5_ ++v#MF* var 5_ **v#MF< $var Model = require("models").Model;5_ **v#MF@var BModel = Model.extend({5_- **v#MFH,.var klass = Model.extend({5_1**v#MFJ02var Collection = Model.extend({5_;**v#MFW:< var Model = Model.extend({5_>.**v#MFf=?0 assert.equal(this.collection, collection);5_>1**v#MFh=?4 assert.equal(this.collection, collection, "");5_>0**v#MFm=@B assert.equal(this.collection, collection, "initialize is ");5_?**v#MFq>@% "initialize is ");5_?;**v#MFv>@> "collection is set before initialize is ");5_H**v#MF~GH/*5_Q**v#MFPR5_O**v#MFNP assert.equal(model.one, 1);5_O**v#MFNP! assert.equal(model.one, 1, "");5_O,**v#MFNP\ assert.equal(model.one, 1, "initialize is called with options passed to the constructor");5_O<**v#MFNPY assert.equal(model.one, 1, "initialize called with options passed to the constructor");5_OL**v#MFNPZ assert.equal(model.one, 1, "initialize called with argument passed to the constructor");5_OH**v#MFNPV assert.equal(model.one, 1, "initialize called with argument passed to constructor");5_OJOJOTvTMFNPX assert.equal(model.one, 1, "initialize called with argument passed to a constructor");5_OJOJOTvTMFNPM assert.equal(model.one, 1, "initialize called with argument passed to a ");5_O5OJOTvTMFNP@ assert.equal(model.one, 1, "initialize called with argument");5_O5OJOTvTMFNPM assert.equal(model.one, 1, "initialize called with constructors argument");5_OBOJOTvTMFNPO assert.equal(model.one, 1, "initialize called with a constructors argument");5_OCOJOTvTMFNPQ assert.equal(model.one, 1, "initialize called with a constructor'ss argument");5_OMOJOTvTMFNPP assert.equal(model.one, 1, "initialize called with a constructor's argument");5_ODOJOTvTMFNPQ assert.equal(model.one, 1, "initialize called with a constructor's arguments");5_IOJOTvTMFHJ var Model = Model.extend({5_QOJOTvTMFPR/*5_QOJOTvTMFPR*5_`OJOTvTMF`b`b5_S5OJOTvTMFRT7 assert.equal(doc.url(), '/collection/1-the-tempest');5_S8OJOTvTMFRT; assert.equal(doc.url(), '/collection/1-the-tempest', "");5_S7OJOTvTMGRUI assert.equal(doc.url(), '/collection/1-the-tempest', "url is correct");5_TOJOTvTMG SU! "url is correct");5_T$OJOTvTMGSUL "url is correct as it takes collection and id into account");5_)OJOTvTMGG; var base = getUrl(this.collection.url) || this.urlRoot;5_1--vMG02 var Collection = GModel.extend({5_V5--vMGVX );UX7 assert.equal(doc.url(), '/collection/1-the-tempest');5_W--vMGVX "");5_X--vMHXZ XZ5_Y--vMH#XZ assert.throws()5_Y--vMH'XZ assert.throws(function())5_Y--vMH'X[ assert.throws(function() {})5_Z--vMH)Y[ })5_Z--vMH+Y[ });5_Z--vMH/Y[ }, "");5_Y--vMHIY[ Y[5_Z --vMHNY[ doc.url()5_]--vMHP\] try {5_]--vMHQ\] doc.url();5_]--vMHQ\] } catch (e) {5_]--vMHR\] failed = true;5_]--vMHR\] }5_]--vMHS \] assert.equal(failed, true);5_ vMH}!< return isFunction(target.url) ? target.url() : target.url;5_   9vMHF return target && isFunction(target.url) ? target.url() : target.url;5_   9vMHG return !target && isFunction(target.url) ? target.url() : target.url;5_   " 9vMH"U return !target ? undefined : && isFunction(target.url) ? target.url() : target.url;5_    9vMI# urlRoot: '/',5_   \  8vMI\^ \^5_  [ 8vMI$Z[ var failed = false;5_ \ 8vMI[] doc5_\ 8vMI[] doc.urlRoot = ''5_\ 8vMI[_ doc.urlRoot = '/'5_] 8vMI"\^5_\\\vMI([] doc.urlRoot = '/'; doc5_Z\\vMI)[^ Z] Z\5____vMI+^_ doc5____vMI,^_5_\__vMI-\^ \^5_]``vMI4\^ assert.equal()5_]``vMI8\^ assert.equal(doc.url())5_]``vMI:\^ assert.equal(doc.url(), '')5_]*``vMII]_ )\_+ assert.equal(doc.url(), '/1-the-tempest')5_^aavMIP]_ "")5_^aavMIb]_" "uses urlRoot if ")5_^aavMIf]_& "fallback urlRoot if ")5_^'aavMIi]_) "fallback to urlRoot if ")5_ ^8aavMIl%]_8 "fallback to urlRoot if property exists")5_! _aavMIo&_a_a5_ "!dbbvMIce/*5_!#"nbbvMI'npnp5_"$#fbbvMIeg var Model = Model.extend({5_#%$fbbvMIeg var Model = GModel.extend({5_$&%fbbvMIeg var Model = Model.extend({5_%'&ibbvMI(hj var model = new Model();5_&('j)bbvMIik+ assert.equal(model.url(), '/collection');5_')(j,bbvMIik/ assert.equal(model.url(), '/collection', "");5_(*)j+bbvMIilS assert.equal(model.url(), '/collection', "if has no id then parent url is used");5_)+*l bbvMIkm model.set({id: '+1+'});5_*,+lbbvMIkm model.set({ id: '+1+'});5_+-,m1bbvMImo );lo3 assert.equal(model.url(), '/collection/%2B1%2B');5_,.-nbbvMI)mo "");5_-/.qbbvMZVpr/*5_.0/bbvMZY5_/10t bbvMZasu a = new Model(attrs);5_021tbbvMZhsu a = new GModel(attrs);5_132ubbvMZjtv b = a.clone();5_243vbbvMZtuw assert.equal(a.get('foo'), 1);5_354v!bbvMZwuw$ assert.equal(a.get('foo'), 1, '');5_465v!bbvMZyuw$ assert.equal(a.get('foo'), 1, "");5_576wbbvMZvx assert.equal(a.get('bar'), 2);5_687w!bbvMZvx$ assert.equal(a.get('bar'), 2, "");5_798xbbvMZwy assert.equal(a.get('baz'), 3);5_8:9x!bbvMZ*wy$ assert.equal(a.get('baz'), 3, "");5_9;:| bbvM\{} a.set({foo : 100});5_:<;|bbvM\{} a.set({ foo : 100});5_;=<} bbvM\*|~" assert.equal(a.get('foo'), 100);5_<>=}!bbvM\+|~$ assert.equal(a.get('foo'), 100'');5_=?>}#bbvM\-|~& assert.equal(a.get('foo'), 100, "");5_>@?}1bbvM\8,|~4 assert.equal(a.get('foo'), 100, "attribute has ");5_?A@tt, v M\tv tv5_@BAut, v M\-tv console.log()5_ACBut, v M\.tu console.log(a.clone)5_BDC v M\/*5_CED v M\5_DFE v M\* attrs = { 'foo': 1, 'bar': 2, 'baz': 3};5_EGFs v M\rt* attrs = { 'foo': 1, 'bar': 2, 'baz': 3};5_FHG, v M\. var attrs = { 'foo': 1, 'bar': 2, 'baz': 3};5_GIH v M\ a = new Model(attrs);5_HJI v M\$ ok(a.isNew(), "it should be new");5_IKJ v M]  var a = new Model(attrs);5_JLK v M]0A ok(a.isNew(), "any defined ID is legal, negative or positive");5_KML v M])/*5_LNM v M]*15_MON. v M]90 assert.equal(doc.get('title'), 'The Tempest');5_NPO1 v M]:4 assert.equal(doc.get('title'), 'The Tempest', "");5_OQP: v M]?< assert.equal(doc.get('title'), 'The Tempest', "correct ");5_PRQ4 v M]F6 assert.equal(doc.get('author'), 'Bill Shakespeare');5_QSR7 v M]G: assert.equal(doc.get('author'), 'Bill Shakespeare', '');5_RUS7 v M]H: assert.equal(doc.get('author'), 'Bill Shakespeare', "");5_SVTU6 v M]YT assert.equal(doc.get('author'), 'Bill Shakespeare', "correct 'author' attribute");5_UWV v M]^/*5_VXW v M]`25_WYXvM] 5_XZY vM] doc.unset()5_Y[Z vM] doc.unset("")5_Z\[ vM] doc.unset("")5_[]\vM] assert.equal doc.unset("audience")5_\^]vM] assert.equal()5_]_^vM] assert.equal(doc.get())5_^`_vM] assert.equal(doc.get(''))5__a`!vM]# assert.equal(doc.get('audience'))5_`ba$vM]' assert.equal(doc.get('audience', ''))5_acb"vM]# assert.equal(doc.get('audience'))5_bdc'vM]' assert.equal(doc.get('audience'), '')5_ced&vM]( assert.equal(doc.get('audience'), '');5_dfe)vM], assert.equal(doc.get('audience'), '', "");5_egfvM]5_fhgvM]2exports["test Model: escape"] = function(assert) {5_gihvM]3 assert.equal(doc.escape('title'), 'The Tempest');5_hjivM]$ doc.set({audience: 'Bill & Bob'});5_ikjvM]9 assert.equal(doc.escape('audience'), 'Bill & Bob');5_jlkvM]$ doc.set({audience: 'Tim > Joan'});5_kmlvM]8 assert.equal(doc.escape('audience'), 'Tim > Joan');5_lnmvM] doc.set({audience: 10101});5_monvM]0 assert.equal(doc.escape('audience'), '10101');5_npovM] doc.unset('audience');5_oqpvM]+ assert.equal(doc.escape('audience'), '');5_prqvM]};5_qsrvM]35_rts&vM^4> assert.equal(doc.get('audience'), '', "property was unset");5_sutvM^/*5_tvuvM^5_uwvvM^55_vxwvM^ attrs = {};5_wyxvM^ a = new Model(attrs);5_xzyvM^ var a = new Model(attrs);5_y{zvM^= _([true, "Truth!", 1, false, '', 0]).each(function(value) {5_z|{$vM^; [true, "Truth!", 1, false, '', 0]).each(function(value) {5_{}|$vM^: [true, "Truth!", 1, false, '', 0].each(function(value) {5_|~}$vM^& assert.equal(a.has("name"), true);5_}~'vM^* assert.equal(a.has("name"), true, "");5_~BvM^6D assert.equal(a.has("name"), true, "attribute `name` was set: ");5_vM^75_#vM^% assert.equal(a.has('name'), false);5_&vM^) assert.equal(a.has('name'), false, "");5_?vM_5_vM_- _([null, undefined]).each(function(value) {5_vM_ + [null, undefined]).each(function(value) {5_vM_ * [null, undefined].each(function(value) {5_ vM_ a.set({'name': value});5_vM_ a.set({ 'name': value});5_ vM_  a.set({'name': value});5_vM_" a.set({ 'name': value});5_%vM_3' assert.equal(a.has("name"), false);5_&vM_5) assert.equal(a.has("name"), false'');5_(vM_7+ assert.equal(a.has("name"), false, "");5_2vM_>9 assert.equal(a.has("name"), false, "attribute name");5_7vM_?8: assert.equal(a.has("name"), false, "attribute `name");5_#vM_Q% assert.equal(a.has("name"), false);5_&vM_S9) assert.equal(a.has("name"), false, "");5_vM_w/*5_vM_z:5_vM_- attrs = {id: 'id', foo: 1, bar: 2, baz: 3};5_vM_ a = new Model(attrs);5_vM_1 var attrs = {id: 'id', foo: 1, bar: 2, baz: 3};5_0vM_2 var attrs = { id: 'id', foo: 1, bar: 2, baz: 3};5_vM_9 a.bind("change:foo", function() { changeCount += 1; });5_ vM_ a.set({'foo': 2});5_vM_ a.set({ 'foo': 2});5_vM_3 ok(a.get('foo')== 2, "Foo should have changed.");5_vM_ var a = new Model(attrs);5_vM_@ ok(changeCount == 1, "Change count should have incremented.");5_vM_? ok(a.get('foo')== 2, "Foo should NOT have changed, still 2");5_vM_D ok(changeCount == 1, "Change count should NOT have incremented.");5_vM_5 ok(a.get('foo')== null, "Foo should have changed");5_vM_J ok(changeCount == 2, "Change count should have incremented for unset.");5_ vM_: assert.ok(a.get('foo')== 2, "Foo should have changed.");5_vM_= assert.equal(a.get('foo')== 2, "Foo should have changed.");5_ vM_G assert.ok(changeCount == 1, "Change count should have incremented.");5_vM_J assert.equal(changeCount == 1, "Change count should have incremented.");5_vM_R a.set({'foo': 2}); // set with value that is not new shouldn't fire change event5_ vM_S a.set({'foo': 2 }); // set with value that is not new shouldn't fire change event5_vM_F assert.ok(a.get('foo')== 2, "Foo should NOT have changed, still 2");5_ vM_E assert.ok(a.get('foo'), 2, "Foo should NOT have changed, still 2");5_ vM_K assert.ok(changeCount == 1, "Change count should NOT have incremented.");5_vM_;N assert.equal(changeCount == 1, "Change count should NOT have incremented.");5_vM_< assert.ok(a.get('foo')== null, "Foo should have changed");5_ vM_; assert.ok(a.get('foo'), null, "Foo should have changed");5_!vM_<> assert.equal(a.get('foo'), null, "Foo should have changed");5_ vM_Q assert.ok(changeCount == 2, "Change count should have incremented for unset.");5_vM_>T assert.equal(changeCount == 2, "Change count should have incremented for unset.");5_vM`/*5_vM`?5_vM` var model = new Model({a: 1});5_vM`! var model = new GModel({a: 1});5_vM`@" var model = new GModel({ a: 1});5_ vM`" model.bind("change:a", counter);5_ vM` model.set({a: 2});5_vM`A model.set({ a: 2});5_)vM`CM assert.equal(i, 2, 'Unset does not fire an event for missing attributes.');5_vM`/*5_vM`5_vM`D5_!vM`7 var MongoModel = Model.extend({idAttribute : '_id'});5_-vM`8 var MongoModel = Model.extend({ idAttribute : '_id'});5_#vM`/ var MongoModel = Model.extend({ '' : '_id'});5_vM`0 var MongoModel = Model.extend({ '@' : '_id'});5_vM`G var model = new MongoModel({id: 'eye-dee', _id: 25, title: 'Model'});5_EvMaEH var model = new MongoModel({ id: 'eye-dee', _id: 25, title: 'Model'});5_!vMa  5_ vMa assert.ok()5_vMa assert.ok(!model.isNew())5_vMa assert.ok(!model.isNew(), "")5_?vMa*? assert.ok(!model.isNew(), "model became new as it has no id")5_"vMa,$ assert.equal(model.id, undefined);5_%vMa/F( assert.equal(model.id, undefined, "");5_"vMa=GM assert.equal(model.id, undefined, "id was unset as primary key was unset");5_vMaA assert.equal(model.id, 25);5_vMaC! assert.equal(model.id, 25, "");5_)vMaX+ assert.equal(model.get('id'), 'eye-dee');5_,vMa]I/ assert.equal(model.get('id'), 'eye-dee', "");5_ vMasJ@ assert.ok(!model.isNew(), "model became new as it has no id");5_vMa{/*5_vMa|K5_vMaL* var model = new Model({name : "Model"});5_vMa+ var model = new GModel({name : "Model"});5_)vMaM, var model = new GModel({ name : "Model"});5_$vMa& assert.equal(model.get('name'), '');5_'vMa* assert.equal(model.get('name'), '', "");5_ vMa model.set({name : ''});5_vMaN model.set({ name : ''});5_vMa/*5_vMaO5_vMa* var model = new Model({name : "Model"});5_vMa+ var model = new GModel({name : "Model"});5_)vMa, var model = new GModel({ name : "Model"});5_&vMaP; model.bind("change:name", function(){ changed = true; });5_vMa assert.equal(changed, true);5_vMaQ" assert.equal(changed, true, "");5_+vMa- assert.equal(model.get('name'), undefined);5_.vMaR1 assert.equal(model.get('name'), undefined, "");5_DvMa 5_vMa assert.equal()5_vMa assert.equal(model.has())5_vMa assert.equal(model.has(''))5_ vMa! assert.equal(model.has('name'))5_)vMa* assert.equal(model.has('name'), false, )5_*vMa, assert.equal(model.has('name'), false, "")5_AvMaTA assert.equal(model.has('name'), false, "name is no longer set")5_ vMbU< model.bind("change:name", function() { changed = true; });5_ vMb"V var changed;5_vMd/*5_vMdW5_vMd var Defaulted = Model.extend({5_vMd) var model = new Defaulted({two: null});5_'vMd* var model = new Defaulted({ two: null});5_"vMd$ assert.equal(model.get('one'), 1);5_%vMd( assert.equal(model.get('one'), 1, "");5_%vMd' assert.equal(model.get('two'), null);5_(vMd+ assert.equal(model.get('two'), null, "");5_vMdX Defaulted = Model.extend({5_vMd) var model = new Defaulted({two: null});5_'vMd* var model = new Defaulted({ two: null});5_vMe+ var model = new Defaulted({ two: null });5_"vMe$ assert.equal(model.get('one'), 3);5_#vMe& assert.equal(model.get('one'), 3'');5_%vMe ( assert.equal(model.get('one'), 3, "");5_%vMe' assert.equal(model.get('two'), null);5_(vMeZ+ assert.equal(model.get('two'), null, "");5_vMf#/*5_vMf&[5_vMf,2 var model = new Model({name : "Tim", age : 10});5_vMf.3 var model = new GModel({name : "Tim", age : 10});5_1vMf0\4 var model = new GModel({ name : "Tim", age : 10});5_ vMfB# model.bind('change', function() {5_vMfR1 assert.equal(model.changedAttributes(), false);5_ vMfT1 ok(model.hasChanged('name'), 'name changed');5_  vMf[! model.on('change', function() {5_   'vMfc* model.on('change', function(attribute) {5_   'vMfq5_   vMfu0 ok(!model.hasChanged('age'), 'age did not');5_  vMfz7 assert.ok(!model.hasChanged('age'), 'age did not');5_ /vMf@ assert.ok(!attributes.age.hasChanged('age'), 'age did not');5_&vMf8 assert.ok(model.hasChanged('name'), 'name changed');5_vMf5_vMf 5_vMf assert.equal5_vMf assert.equal()5_vMf& assert.equal(attribute.previous, )5_)vMf* assert.equal(attribute.age.previous, )5_*vMf, assert.equal(attribute.age.previous, "")5_*vMf, assert.equal(attribute.age.previous, '')5_.vMf/ assert.equal(attribute.age.previous, 'Tim')5_1vMf3 assert.equal(attribute.age.previous, 'Tim', "")5_MvMfM assert.equal(attribute.age.previous, 'Tim', "previous attributes passed")5_vMf]N assert.equal(attribute.age.previous, 'Tim', "previous attributes passed");5_vMf 5_vMf assert.equal()5_'vMf) assert.equal(attribute.age.value, "")5_ .vMfO assert.equal(attributes.age.previous, 'Tim', "previous attributes passed");5_! +vMfL assert.equal(attributes.age.previous, "", "previous attributes passed");5_ "!+vMf, assert.equal(attribute.age.value, "Rob")5_!#".vMf0 assert.equal(attribute.age.value, "Rob", "")5_"$#EvMfO assert.equal(attributes.age.previous, "Tim", "previous attributes passed");5_#%$@vMfJ assert.equal(attributes.age.previous, "Tim", "previous value passed");5_$&%CvMfC assert.equal(attribute.age.value, "Rob", "new value is passed")5_%'&vMf^D assert.equal(attribute.age.value, "Rob", "new value is passed");5_&('vMgl ok(_.isEqual(model.changedAttributes(), {name : 'Rob'}), 'changedAttributes returns the changed attrs');5_')(vMg 0 assert.equal(model.previous('name'), 'Tim');5_(*)vMg _i ok(_.isEqual(model.previousAttributes(), {name : "Tim", age : 10}), 'previousAttributes is correct');5_)+* vMg - model.set({name : 'Rob'}, {silent : true});5_*,+vMg. model.set({ name : 'Rob'}, {silent : true});5_+-,vMg/ model.set({ name : 'Rob' }, {silent : true});5_,.--vMg`0 model.set({ name : 'Rob' }, { silent : true});5_-/.vMg"1 model.set({ name : 'Rob' }, { silent : true });5_.0/vMg#) assert.equal(model.hasChanged(), true);5_/20vMg'/ assert.equal(model.hasChanged('name'), true);5_0312vMg3a3 //model.set({ name : 'Rob' }, { silent : true });5_243vMg=b model.change();5_354'vMg) assert.equal(model.get('name'), 'Rob');5_465+vMg- assert.equal(model.get('name'), 'Rob', "");5_576*vMgc- assert.equal(model.get('name'), 'Rob', '');5_687>vMgA assert.equal(model.get('name'), 'Rob', 'property was updated');5_798)vMgA assert.equal(model.get('name'), 'Rob', 'property was updated");5_8:9*vMgA assert.equal(model.get('name'), 'Rob', "property was updated");5_9;:3vMgdA assert.equal(model.get('name'), 'Rob', "property was updated");5_:<;vMg/*5_;=<vMg5_<>=vMge 5_=?>vMg' var model = new Model({name: 'Rob'});5_>@?%vMgf( var model = new Model({ name: 'Rob'});5_?A@vMg) var model = new Model({ name: 'Rob' });5_@BA vMg 1 model.bind('change', function(model, options) {5_ACBvMgg / model.on('change', function(model, options) {5_BDC vMhI  + model.set({name: 'Bob'}, {silent: true});5_CED vMhK  , model.set({ name: 'Bob'}, {silent: true});5_DFE vMhM  - model.set({ name: 'Bob' }, {silent: true});5_EGF +vMhN  . model.set({ name: 'Bob' }, { silent: true});5_FHG vMhR  ! model.change({prefix: 'Mr. '});5_GIH vMhT  " model.change({ prefix: 'Mr. '});5_HJI vMhg - model.set({name: 'Sue'}, {prefix: 'Ms. '});5_IKJvMhi . model.set({ name: 'Sue'}, {prefix: 'Ms. '});5_JLKvMhj / model.set({ name: 'Sue' }, {prefix: 'Ms. '});5_KML-vMhmh 0 model.set({ name: 'Sue' }, { prefix: 'Ms. '});5_LNM vMhi  # model.change({ prefix: 'Mr. ' });5_MON vMh ! assert.equal(value, 'Mr. Bob');5_NPO vMh  % //model.change({ prefix: 'Mr. ' });5_OQP vMhj     5_PRQvMh! assert.equal(value, 'Ms. Sue');5_QSR"vMhk% assert.equal(value, 'Ms. Sue', "");5_RTSvMh/*5_SUTvMh5_TVUvMh5_UWVvMh var obj = new Model(attrs);5_VXWvMh" var attrs = {id: 1, label: 'c'};5_WYX!vMh# var attrs = { id: 1, label: 'c'};5_XZY vMh3 obj.bind('change', function() { changed += 1; });5_Y[ZvMh assert.equal(changed, 0);5_Z\[vMhm assert.equal(changed, 0, "");5_[]\)vMinQ assert.equal(changed, 0, "change event is not emitted if values don't change");5_\^]vMi/*5_]_^vMi5_^`_$vMio$&$&5__a`vMiC var model = new Model({firstName : "Taylor", lastName: "Swift"});5_`baAvMi!pD var model = new Model({ firstName : "Taylor", lastName: "Swift"});5_acbvMi%E var model = new Model({ firstName : "Taylor", lastName: "Swift" });5_bdcvMi(q$ model.bind('change', function () {5_ced vMi1! !5_dfe vMiF! assert.equal()5_egf vMiI! assert.equal(lastRequest[])5_fhg vMiJ! assert.equal(lastRequest[1])5_gih &vMi^!' assert.equal(lastRequest[1], model)5_hji )vMi`!+ assert.equal(lastRequest[1], model, '')5_ikj!vMie !) ok(_.isEqual(lastRequest[1], model));5_jlkvMik 5_kml!=vMi "? assert.equal(lastRequest[1], model, 'sync is called with ')5_lnm!IvMi "I assert.equal(lastRequest[1], model, 'sync is called with this model')5_mon# vMi"$! model.set({lastName: 'Hicks'});5_nvo#vMir"$" model.set({ lastName: 'Hicks'});5_owpvvMi! !5_vxw vMi! try {}5_wyx!vMi!# !#5_xzy" vMj!# } catch()5_y{z"vMj!# } catch(e)5_z|{"vMj!# } catch(e) {}5_{}|"vMj t!#! } catch(e) { console.error()}5_|~} vMj  try {5_}~!vMju !( } catch(e) { console.error(e.stack)}5_~&vMj%&/*5_+vMj+-+-5_,vMjv+-?*5_' vMk&( doc.save({title : "Henry V"});5_'vMkw&(! doc.save({ title : "Henry V"});5_vMk:x5_vMkL var BModel = GModel.extend({ url: function url() {7 var base = getUrl(this.collection) || this.urlRoot; return this.isNew() ? base :< normalizeURL(base) + encodeURIComponent(this.id); }});BModel.sync = sync;// Stub out request...5_vMkM5_vMkN5_ vMkQ + "5_*vMkSz)*5_)'vMkf(*) assert.equal(lastRequest[0], 'update');5_)*vMkh(*- assert.equal(lastRequest[0], 'update', "");5_*vMkw)+% ok(_.isEqual(lastRequest[1], doc));5_*vMk})+/ assert.equal(_.isEqual(lastRequest[1], doc));5_*#vMk)+% assert.equal(lastRequest[1], doc));5_*%vMk)+( assert.equal(lastRequest[1], doc, "");5_*/vMk{)+2 assert.equal(lastRequest[1], doc, "model was ");5_-vMk,-/*5_2vMk|24245_/vMk.0 ok(lastRequest[0], 'read');5_/"vMk.0$ assert.ok(lastRequest[0], 'read');5_/%vMk.0( assert.ok(lastRequest[0], 'read', "");5_/4vMk.0; assert.ok(lastRequest[0], 'read', "fetch triggers read");5_/9vMk}.0< assert.ok(lastRequest[0], 'read', "fetch triggers `read");5_0vMk/1% ok(_.isEqual(lastRequest[1], doc));5_0vMk/1, assert.ok(_.isEqual(lastRequest[1], doc));5_0 vMk/1" assert.ok(lastRequest[1], doc));5_0"vMk~/1% assert.ok(lastRequest[1], doc, "");5_/ vMlJ.0E assert.ok(lastRequest[0], 'read', "fetch triggers `read` on sync");5_0 vMlN/1B assert.ok(lastRequest[1], doc, "module passed is target model");5_3vMlV23/*5_8vMlX8:8:5_2vMn24245_3vMo23/*5_5'vMo 46) assert.equal(lastRequest[0], 'delete');5_5*vMo 46- assert.equal(lastRequest[0], 'delete', "");5_6vMo57% ok(_.isEqual(lastRequest[1], doc));5_6#vMo$57% assert.equal(lastRequest[1], doc));5_6%vMo'57( assert.equal(lastRequest[1], doc, '');5_6/vMo.572 assert.equal(lastRequest[1], doc, 'model was ');5_6+vMo157> assert.equal(lastRequest[1], doc, 'model was target model');5_6JvMo857M assert.equal(lastRequest[1], doc, 'model passed to sync was target model');5_6$vMo:57M assert.equal(lastRequest[1], doc, 'model passed to sync was target model");5_9vMoC89/*5_NvMoENPNP5_;vMoO:< var model = new Model();5_<vMod<>5_=vMof<=5_=vMon<?9 if (attrs.admin) return "Can't change admin status.";5_>6vMow=?7 throw new TypeError("Can't change admin status.";5_@ vMo?A. model.bind('error', function(model, error) {5_CvMoBD# var result = model.set({a: 100});5_C!vMoBD$ var result = model.set({ a: 100});5_DvMoCE assert.equal(result, model);5_DvMoCE" assert.equal(result, model, "");5_D+vMoCE3 assert.equal(result, model, "set returns model");5_E"vMoDF$ assert.equal(model.get('a'), 100);5_E%vMoDF( assert.equal(model.get('a'), 100, "");5_F#vMoEG% assert.equal(lastError, undefined);5_F&vMoEG) assert.equal(lastError, undefined, "");5_GvMoFH4 result = model.set({admin: true}, {silent: true});5_G"vMoFH5 result = model.set({ admin: true}, {silent: true});5_G'vMoFH6 result = model.set({ admin: true }, {silent: true});5_G4vMoFH7 result = model.set({ admin: true }, { silent: true});5_F6vMoFH FH5_>vMpw>@ >@5_HvMpGH return5_GvMpGI GI5_K vMpKM5_LvMpKM5_HvMpHJ // HJ5_HvMpGI! // TODO: Consider silent errors5_QvMpRT assert.throwsQT QS5_SvMqRT assert.throws()5_SvMqRT assert.throws(function())5_SvMq SU model.set})RU assert.throws(function() {})5_TvMqSU model.set()})5_TvMqSU model.set({})})5_T&vMqSV( model.set({ a: 200, admin: true })})5_UvMqTV })5_UvMq TV });5_U vMq#TV }, /Can'');5_U#vMq/TV& }, /Can't change admin status/, "");5_U#vMq7TV: }, /Can't change admin status/, "invalid attiributes ");5_U?vMq<TVB }, /Can't change admin status/, "setting invalid attiributes ");5_UCvMqPUW5_VP#PvMqbUW5_V"P#PvMqeUW$ assert.equal(model.get('a'), 100);5_V%P#PvMqgUW( assert.equal(model.get('a'), 100, "");5_V8P#PvMqzUWJ assert.equal(model.get('a'), 100, "valid attribute was not set either");5_YP#PvMqXY/*5_pP#PvMqprpr5_[P#PvMqZ\' var model = new Model({name: "One"});5_[P#PvMqZ\( var model = new BModel({name: "One"});5_[&P#PvMqZ\) var model = new BModel({ name: "One"});5_`P#PvMq_a return "No thanks.";5_`P#PvMq_a throw "No thanks.";5_`P#PvMq_a( throw new TypeError"No thanks.";5_`(P#PvMq_a) throw new TypeError("No thanks.";5_bP#PvMqbd bd5_e P#PvMqdf model.set({name: "Two"});5_eP#PvMqdf model.set({ name: "Two"});5_f'P#PvMqeg) assert.equal(model.get('name'), 'Two');5_f*P#PvMqeg- assert.equal(model.get('name'), 'Two', "");5_j'P#PvMqik) assert.equal(model.get('name'), 'Two');5_j*P#PvMqik- assert.equal(model.get('name'), 'Two', "");5_\P#PvMr\^ \^5_]P#PvMr\^ console.log()5_]P#PvMt|\] console.log(attrs)5_l'P#PvMtkm) assert.equal(model.get('name'), 'Two');5_l*P#PvMtkm- assert.equal(model.get('name'), 'Two', "");5_l<P#PvMtkm? assert.equal(model.get('name'), 'Two', "name was not unset");5_j7P#PvMtik: assert.equal(model.get('name'), 'Two', "name is unset");5_g P#PvMtgi gi5_hP#PvMtgi assert.throws()5_hP#PvMtgi assert.throws(function())5_hP#PvMthk hj5_iP#PvMthi5_hP#PvMtgj assert.throws(function() {})5_hP#PvMthj hj5_iP#PvMthj model.unset()5_iP#PvMthj model.unset('')5_jP#PvMtik });5_jP#PvMtik }, /No thanks/, "");5_lP#PvMtkl model.unset('name');5_iP#PvMthj model.unset('name')5_kP#PvMtjk5_gP#PvMtfh! assert.equal(error, undefined);5_g"P#PvMtfh% assert.equal(error, undefined, "");5_kP#PvMujk assert.equal(error, true);5__P#PvMu^_ error = true;5_fP#PvMu.ef9 assert.equal(error, undefined, "no errors are logged");5_ZP#PvMu2YZ var error;5_gP#PvMuWfh# }, /No thanks/, "can not unset");5_g#P#PvMuZfh& }, /No thanks/, "can not be unset");5_ g4P#PvMumfh7 }, /No thanks/, "can not be unset to invalid value");5_   ZZZ'v'MuZ\ Z\5_   [ZZ'v'MuZ[ var 5_  m+ZZ'v'Muln- assert.equal(model.get('name'), undefined);5_ m,ZZ'v'Muln/ assert.equal(model.get('name'), undefined'');5_m.ZZ'v'Muln1 assert.equal(model.get('name'), undefined, "");5_l ZZ'v'Mukm model.clear();5_hZZ'v'Mvhj hj5_iZZ'v'Mvhj assert.thorws()5_iZZ'v'Mvhj assert.thorws(function())5_jZZ'v'Mvik model.clear();5_jZZ'v'Mvjl jl5_kZZ'v'Mv jl }, /No thanks/, ""5_k3ZZ'v'Mv0jl3 }, /No thanks/, "can not be cleared to undefinde"5_iZZ'v'Mv:hj assert.thorws(function()5_iZZ'v'Mv<hj assert.thorws(function() {}5_i ZZ'v'Mv\hj assert.thorws(function() {5_i ZZ'v'Mv^hj assert.throrws(function() {5_n ZZ'v'Mvnmo model.unset();5_ d ZZ'v'Mxdf df5_! eZZ'v'Mxdf0 // TODO: Consider validation on unset / clear.5_ "!nZZ'v'Mxnp np5_!#"tZZ'v'Mxst/*5_"$#ZZ'v'Mx5_#%$vZZ'v'Mxuw var model = new Model();5_$&%xZZ'v'Mxwz9 if (attrs.admin) return "Can't change admin status.";5_%'&y7ZZ'v'Mxxz7 throw new TypeError("Can't change admin status.";5_&('~ ZZ'v'My}. model.bind('error', function(model, error) {5_')(ZZ'v'My 6 var result = model.set({a: 100}, {error: callback});5_(*)!ZZ'v'My7 var result = model.set({ a: 100}, {error: callback});5_)+*%ZZ'v'My8 var result = model.set({ a: 100 }, {error: callback});5_*,+$ZZ'v'My7 var result = model.set({ a: 100 },{error: callback});5_+-,&ZZ'v'My8 var result = model.set({ a: 100 }, {error: callback});5_,.-6ZZ'v'My9 var result = model.set({ a: 100 }, { error: callback});5_-/.ZZ'v'My& assert.equal(result, model);5_.0/ZZ'v'My(" assert.equal(result, model, '');5_/10ZZ'v'My)" assert.equal(result, model, "");5_021"ZZ'v'My8$ assert.equal(model.get('a'), 100);5_132#ZZ'v'My8& assert.equal(model.get('a'), 100'');5_243%ZZ'v'My:( assert.equal(model.get('a'), 100, "");5_354ZZ'v'MyG? result = model.set({a: 200, admin: true}, {error: callback});5_465*ZZ'v'MyI@ result = model.set({ a: 200, admin: true}, {error: callback});5_576y*ZZ'v'MyMy{ y{5_687zZZ'v'MyXy{ return attribute5_798zZZ'v'MyZy{ return attribute5_8:9/ZZ'v'MyuA result = model.set({ a: 200, admin: true }, {error: callback});5_9;:?ZZ'v'MywB result = model.set({ a: 200, admin: true }, { error: callback});5_:<;#ZZ'v'My{% assert.equal(lastError, undefined);5_;=<&ZZ'v'My|) assert.equal(lastError, undefined, "");5_<>=3ZZ'v'My: assert.equal(lastError, undefined, "there was no erro");5_=?>*ZZ'v'My- assert.equal(lastError, undefined, "erro");5_>@?$ZZ'v'My& assert.equal(boundError, undefined);5_?A@'ZZ'v'My* assert.equal(boundError, undefined, "");5_@BA,ZZ'v'My/ assert.equal(boundError, undefined, "error");5_ACBZZ'v'MyC result = model.set({ a: 200, admin: true }, { error: callback });5_BDCZZ'v'MyF // result = model.set({ a: 200, admin: true }, { error: callback });5_CEDEZZ'v'My }, E result = model.set({ a: 200, admin: true }, { error: callback });5_DFEZZ'v'My }, ""5_EGFZZ'v'My }, /admin status/, ""5_FHGZZ'v'My1 }, /admin status/, "wrong attribute will throw"5_GIH$ZZ'v'My9 }, /admin status/, "setting wrong attribute will throw"5_HJI/ZZ'v'My; }, /admin status/, "setting invalid attribute will throw"5_IKJ6ZZ'v'My< }, /admin status/, "setting invalid attributes will throw"5_JLK6ZZ'v'My7 }, /admin status/, "setting invalid attributes throw"5_KML8ZZ'v'My8 }, /admin status/, "setting invalid attributes throws"5_LNMZZ'v'My assert.equal(result, false);5_MONZZ'v'My 5_NPO"ZZ'v'Mz$ assert.equal(model.get('a'), 100);5_OQP%ZZ'v'Mz ( assert.equal(model.get('a'), 100, "");5_PRQZZ'v'Mz68 assert.equal(lastError, "Can't change admin status.");5_QSRZZ'v'Mz8& assert.equal(boundError, undefined);5_RTSZZ'v'MzA/*5_SUTZZ'v'MzE*/5_TVUZZ'v'MzI var Parent = Model.extend({5_UWVZZ'v'MzV }, {5_VXWZZ'v'Mz` Parent.classProp = function() {} classProp: function() {}5_WYXZZ'v'Mzc });5_XZY"ZZ'v'Mze" Parent.classProp = function() {}5_Y[Z"ZZ'v'Mzg5_Z\[0ZZ'v'Mzw2 assert.equal(Child.classProp, Parent.classProp);5_[]\3ZZ'v'Mz6 assert.equal(Child.classProp, Parent.classProp, "");5_\^]9ZZ'v'MzL assert.equal(Child.classProp, Parent.classProp, "child inherits statics");5_]_^,ZZ'v'Mz. assert.notEqual(Child.classProp, undefined);5_^`_/ZZ'v'Mz2 assert.notEqual(Child.classProp, undefined, "");5__a`ZZ'v'MzC assert.notEqual(Child.classProp, undefined, "static is defiend");5_`ba;ZZ'v'Mz );= assert.equal(kid.instancePropSame, adult.instancePropSame);5_acbZZ'v'Mz "");5_bdcZZ'v'Mz "inherits ");5_ced3ZZ'v'MzF assert.equal(Child.classProp, Parent.classProp, "inherits statics");5_dfe"ZZ'v'Mz% "decedent inherits ");5_egf"ZZ'v'Mz/ "decedent inherits properties");5_fhgZZ'v'Mz3 assert.notEqual(kid.instancePropSame, undefined);5_gihZZ'v'M{? assert.notEqual(Child.prototype.instancePropDiff, undefined);5_hji2ZZ'v'M{ W assert.notEqual(Child.prototype.instancePropDiff, Parent.prototype.instancePropDiff);5_ikj8ZZ'v'M{K assert.notEqual(kid.instancePropDiff, Parent.prototype.instancePropDiff);5_jlk>ZZ'v'M{ );@ assert.notEqual(kid.instancePropDiff, adult.instancePropDiff);5_kmlZZ'v'M{ "");5_lm M@# %var GModel = require("models").Model;5_lZZ'v'Mukm model.unset("");5_lZZ'v'Mukm model.unset("name");5_   ZZZ'v'MuY[ var model = new BModel();5_  c cc v Mubd model.set();5_j'P#PvMrik> assert.equal(model.get('name'), undefined, "name is unset");5_oqvp vMi!function sync() { % lastRequest = toArray(arguments); }5_prq!$vMi "# lastRequest = toArray(arguments);}5_qsr vMi !  " console.log()5_rts!vMi " console.log('')5_sut!vMis " console.log('>>>>>>')5_tu!vMi "5_021vMg) //model.change();5_vMa' assert.ok(model.has('name'), false, )5_ vMa( assert.ok(!model.has('name'), false, )5_SUT" v M]T! assert.equal(doc.get('author'),4 'Bill Shakespeare', "correct 'author' attribute");5_; **v#MF2:< var = Model.extend({5_dfeEWWvM</ var base = getUrl(this.collection) || this.5_465  vMS {function(sync) {5