sync.js (lodash-4.0.0) | : | sync.js (lodash-4.17.21) | ||
---|---|---|---|---|
(function() { | (function(QUnit) { | |||
var Library = Backbone.Collection.extend({ | var Library = Backbone.Collection.extend({ | |||
url: function() { return '/library'; } | url: function() { return '/library'; } | |||
}); | }); | |||
var library; | var library; | |||
var attrs = { | var attrs = { | |||
title: 'The Tempest', | title: 'The Tempest', | |||
author: 'Bill Shakespeare', | author: 'Bill Shakespeare', | |||
length: 123 | length: 123 | |||
skipping to change at line 145 | skipping to change at line 145 | |||
emulateJSON: true | emulateJSON: true | |||
}); | }); | |||
assert.equal(this.ajaxSettings.url, '/library/2-the-tempest'); | assert.equal(this.ajaxSettings.url, '/library/2-the-tempest'); | |||
assert.equal(this.ajaxSettings.type, 'POST'); | assert.equal(this.ajaxSettings.type, 'POST'); | |||
assert.equal(JSON.stringify(this.ajaxSettings.data), '{"_method":"DELETE"}') ; | assert.equal(JSON.stringify(this.ajaxSettings.data), '{"_method":"DELETE"}') ; | |||
}); | }); | |||
QUnit.test('urlError', function(assert) { | QUnit.test('urlError', function(assert) { | |||
assert.expect(2); | assert.expect(2); | |||
var model = new Backbone.Model(); | var model = new Backbone.Model(); | |||
assert.throws(function() { | assert.raises(function() { | |||
model.fetch(); | model.fetch(); | |||
}); | }); | |||
model.fetch({url: '/one/two'}); | model.fetch({url: '/one/two'}); | |||
assert.equal(this.ajaxSettings.url, '/one/two'); | assert.equal(this.ajaxSettings.url, '/one/two'); | |||
}); | }); | |||
QUnit.test('#1052 - `options` is optional.', function(assert) { | QUnit.test('#1052 - `options` is optional.', function(assert) { | |||
assert.expect(0); | assert.expect(0); | |||
var model = new Backbone.Model(); | var model = new Backbone.Model(); | |||
model.url = '/test'; | model.url = '/test'; | |||
Backbone.sync('create', model); | Backbone.sync('create', model); | |||
}); | }); | |||
QUnit.test('Backbone.ajax', function(assert) { | QUnit.test('Backbone.ajax', function(assert) { | |||
assert.expect(1); | assert.expect(1); | |||
Backbone.ajax = function(settings){ | Backbone.ajax = function(settings) { | |||
assert.strictEqual(settings.url, '/test'); | assert.strictEqual(settings.url, '/test'); | |||
}; | }; | |||
var model = new Backbone.Model(); | var model = new Backbone.Model(); | |||
model.url = '/test'; | model.url = '/test'; | |||
Backbone.sync('create', model); | Backbone.sync('create', model); | |||
}); | }); | |||
QUnit.test('Call provided error callback on error.', function(assert) { | QUnit.test('Call provided error callback on error.', function(assert) { | |||
assert.expect(1); | assert.expect(1); | |||
var model = new Backbone.Model; | var model = new Backbone.Model; | |||
skipping to change at line 231 | skipping to change at line 231 | |||
return false; | return false; | |||
} | } | |||
}); | }); | |||
assert.strictEqual(this.ajaxSettings.beforeSend(xhr), false); | assert.strictEqual(this.ajaxSettings.beforeSend(xhr), false); | |||
}); | }); | |||
QUnit.test('#2928 - Pass along `textStatus` and `errorThrown`.', function(asse rt) { | QUnit.test('#2928 - Pass along `textStatus` and `errorThrown`.', function(asse rt) { | |||
assert.expect(2); | assert.expect(2); | |||
var model = new Backbone.Model; | var model = new Backbone.Model; | |||
model.url = '/test'; | model.url = '/test'; | |||
model.on('error', function(model, xhr, options) { | model.on('error', function(m, xhr, options) { | |||
assert.strictEqual(options.textStatus, 'textStatus'); | assert.strictEqual(options.textStatus, 'textStatus'); | |||
assert.strictEqual(options.errorThrown, 'errorThrown'); | assert.strictEqual(options.errorThrown, 'errorThrown'); | |||
}); | }); | |||
model.fetch(); | model.fetch(); | |||
this.ajaxSettings.error({}, 'textStatus', 'errorThrown'); | this.ajaxSettings.error({}, 'textStatus', 'errorThrown'); | |||
}); | }); | |||
})(); | })(QUnit); | |||
End of changes. 5 change blocks. | ||||
4 lines changed or deleted | 4 lines changed or added |