mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-29 06:27:49 +00:00
Update vendors.
This commit is contained in:
30
vendor/backbone/backbone.js
vendored
30
vendor/backbone/backbone.js
vendored
@@ -23,7 +23,7 @@
|
||||
// Next for Node.js or CommonJS. jQuery may not be needed as a module.
|
||||
} else if (typeof exports !== 'undefined') {
|
||||
var _ = require('underscore'), $;
|
||||
try { $ = require('jquery'); } catch(e) {}
|
||||
try { $ = require('jquery'); } catch (e) {}
|
||||
factory(root, exports, _, $);
|
||||
|
||||
// Finally, as a browser global.
|
||||
@@ -31,7 +31,7 @@
|
||||
root.Backbone = factory(root, {}, root._, (root.jQuery || root.Zepto || root.ender || root.$));
|
||||
}
|
||||
|
||||
}(function(root, Backbone, _, $) {
|
||||
})(function(root, Backbone, _, $) {
|
||||
|
||||
// Initial Setup
|
||||
// -------------
|
||||
@@ -207,7 +207,7 @@
|
||||
var context = options.context, ctx = options.ctx, listening = options.listening;
|
||||
if (listening) listening.count++;
|
||||
|
||||
handlers.push({ callback: callback, context: context, ctx: context || ctx, listening: listening });
|
||||
handlers.push({callback: callback, context: context, ctx: context || ctx, listening: listening});
|
||||
}
|
||||
return events;
|
||||
};
|
||||
@@ -619,8 +619,8 @@
|
||||
// the model will be valid when the attributes, if any, are set.
|
||||
if (attrs && !wait) {
|
||||
if (!this.set(attrs, options)) return false;
|
||||
} else {
|
||||
if (!this._validate(attrs, options)) return false;
|
||||
} else if (!this._validate(attrs, options)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// After a successful server-side save, the client is (optionally)
|
||||
@@ -732,8 +732,8 @@
|
||||
|
||||
// Underscore methods that we want to implement on the Model, mapped to the
|
||||
// number of arguments they take.
|
||||
var modelMethods = { keys: 1, values: 1, pairs: 1, invert: 1, pick: 0,
|
||||
omit: 0, chain: 1, isEmpty: 1 };
|
||||
var modelMethods = {keys: 1, values: 1, pairs: 1, invert: 1, pick: 0,
|
||||
omit: 0, chain: 1, isEmpty: 1};
|
||||
|
||||
// Mix in each Underscore method as a proxy to `Model#attributes`.
|
||||
addUnderscoreMethods(Model, modelMethods, 'attributes');
|
||||
@@ -840,7 +840,7 @@
|
||||
var remove = options.remove;
|
||||
|
||||
var sort = false;
|
||||
var sortable = this.comparator && (at == null) && options.sort !== false;
|
||||
var sortable = this.comparator && at == null && options.sort !== false;
|
||||
var sortAttr = _.isString(this.comparator) ? this.comparator : null;
|
||||
|
||||
// Turn bare objects into model references, and prevent invalid models
|
||||
@@ -1065,7 +1065,7 @@
|
||||
},
|
||||
|
||||
// Define how to uniquely identify models in the collection.
|
||||
modelId: function (attrs) {
|
||||
modelId: function(attrs) {
|
||||
return attrs[this.model.prototype.idAttribute || 'id'];
|
||||
},
|
||||
|
||||
@@ -1122,7 +1122,7 @@
|
||||
|
||||
// Method for checking whether an object should be considered a model for
|
||||
// the purposes of adding to the collection.
|
||||
_isModel: function (model) {
|
||||
_isModel: function(model) {
|
||||
return model instanceof Model;
|
||||
},
|
||||
|
||||
@@ -1168,7 +1168,7 @@
|
||||
// Underscore methods that we want to implement on the Collection.
|
||||
// 90% of the core usefulness of Backbone Collections is actually implemented
|
||||
// right here:
|
||||
var collectionMethods = { forEach: 3, each: 3, map: 3, collect: 3, reduce: 0,
|
||||
var collectionMethods = {forEach: 3, each: 3, map: 3, collect: 3, reduce: 0,
|
||||
foldl: 0, inject: 0, reduceRight: 0, foldr: 0, find: 3, detect: 3, filter: 3,
|
||||
select: 3, reject: 3, every: 3, all: 3, some: 3, any: 3, include: 3, includes: 3,
|
||||
contains: 3, invoke: 0, max: 3, min: 3, toArray: 1, size: 1, first: 3,
|
||||
@@ -1687,7 +1687,7 @@
|
||||
}
|
||||
|
||||
// Add a cross-platform `addEventListener` shim for older browsers.
|
||||
var addEventListener = window.addEventListener || function (eventName, listener) {
|
||||
var addEventListener = window.addEventListener || function(eventName, listener) {
|
||||
return attachEvent('on' + eventName, listener);
|
||||
};
|
||||
|
||||
@@ -1708,7 +1708,7 @@
|
||||
// but possibly useful for unit testing Routers.
|
||||
stop: function() {
|
||||
// Add a cross-platform `removeEventListener` shim for older browsers.
|
||||
var removeEventListener = window.removeEventListener || function (eventName, listener) {
|
||||
var removeEventListener = window.removeEventListener || function(eventName, listener) {
|
||||
return detachEvent('on' + eventName, listener);
|
||||
};
|
||||
|
||||
@@ -1802,7 +1802,7 @@
|
||||
// fragment to store history.
|
||||
} else if (this._wantsHashChange) {
|
||||
this._updateHash(this.location, fragment, options.replace);
|
||||
if (this.iframe && (fragment !== this.getHash(this.iframe.contentWindow))) {
|
||||
if (this.iframe && fragment !== this.getHash(this.iframe.contentWindow)) {
|
||||
var iWindow = this.iframe.contentWindow;
|
||||
|
||||
// Opening and closing the iframe tricks IE7 and earlier to push a
|
||||
@@ -1894,4 +1894,4 @@
|
||||
|
||||
return Backbone;
|
||||
|
||||
}));
|
||||
});
|
||||
|
||||
372
vendor/backbone/test/collection.js
vendored
372
vendor/backbone/test/collection.js
vendored
File diff suppressed because it is too large
Load Diff
160
vendor/backbone/test/events.js
vendored
160
vendor/backbone/test/events.js
vendored
@@ -1,11 +1,11 @@
|
||||
(function() {
|
||||
|
||||
QUnit.module("Backbone.Events");
|
||||
QUnit.module('Backbone.Events');
|
||||
|
||||
QUnit.test("on and trigger", function(assert) {
|
||||
QUnit.test('on and trigger', function(assert) {
|
||||
assert.expect(2);
|
||||
var obj = { counter: 0 };
|
||||
_.extend(obj,Backbone.Events);
|
||||
var obj = {counter: 0};
|
||||
_.extend(obj, Backbone.Events);
|
||||
obj.on('event', function() { obj.counter += 1; });
|
||||
obj.trigger('event');
|
||||
assert.equal(obj.counter, 1, 'counter should be incremented.');
|
||||
@@ -16,9 +16,9 @@
|
||||
assert.equal(obj.counter, 5, 'counter should be incremented five times.');
|
||||
});
|
||||
|
||||
QUnit.test("binding and triggering multiple events", function(assert) {
|
||||
QUnit.test('binding and triggering multiple events', function(assert) {
|
||||
assert.expect(4);
|
||||
var obj = { counter: 0 };
|
||||
var obj = {counter: 0};
|
||||
_.extend(obj, Backbone.Events);
|
||||
|
||||
obj.on('a b c', function() { obj.counter += 1; });
|
||||
@@ -37,8 +37,8 @@
|
||||
assert.equal(obj.counter, 5);
|
||||
});
|
||||
|
||||
QUnit.test("binding and triggering with event maps", function(assert) {
|
||||
var obj = { counter: 0 };
|
||||
QUnit.test('binding and triggering with event maps', function(assert) {
|
||||
var obj = {counter: 0};
|
||||
_.extend(obj, Backbone.Events);
|
||||
|
||||
var increment = function() {
|
||||
@@ -68,8 +68,8 @@
|
||||
assert.equal(obj.counter, 5);
|
||||
});
|
||||
|
||||
QUnit.test("binding and triggering multiple event names with event maps", function(assert) {
|
||||
var obj = { counter: 0 };
|
||||
QUnit.test('binding and triggering multiple event names with event maps', function(assert) {
|
||||
var obj = {counter: 0};
|
||||
_.extend(obj, Backbone.Events);
|
||||
|
||||
var increment = function() {
|
||||
@@ -96,9 +96,9 @@
|
||||
assert.equal(obj.counter, 5);
|
||||
});
|
||||
|
||||
QUnit.test("binding and trigger with event maps context", function(assert) {
|
||||
QUnit.test('binding and trigger with event maps context', function(assert) {
|
||||
assert.expect(2);
|
||||
var obj = { counter: 0 };
|
||||
var obj = {counter: 0};
|
||||
var context = {};
|
||||
_.extend(obj, Backbone.Events);
|
||||
|
||||
@@ -110,12 +110,12 @@
|
||||
|
||||
obj.off().on({
|
||||
a: function() {
|
||||
strictEqual(this, context, 'will not override explicit `context` param');
|
||||
assert.strictEqual(this, context, 'will not override explicit `context` param');
|
||||
}
|
||||
}, this, context).trigger('a');
|
||||
});
|
||||
|
||||
QUnit.test("listenTo and stopListening", function(assert) {
|
||||
QUnit.test('listenTo and stopListening', function(assert) {
|
||||
assert.expect(1);
|
||||
var a = _.extend({}, Backbone.Events);
|
||||
var b = _.extend({}, Backbone.Events);
|
||||
@@ -126,7 +126,7 @@
|
||||
b.trigger('anything');
|
||||
});
|
||||
|
||||
QUnit.test("listenTo and stopListening with event maps", function(assert) {
|
||||
QUnit.test('listenTo and stopListening with event maps', function(assert) {
|
||||
assert.expect(4);
|
||||
var a = _.extend({}, Backbone.Events);
|
||||
var b = _.extend({}, Backbone.Events);
|
||||
@@ -141,11 +141,11 @@
|
||||
b.trigger('event event2');
|
||||
});
|
||||
|
||||
QUnit.test("stopListening with omitted args", function(assert) {
|
||||
QUnit.test('stopListening with omitted args', function(assert) {
|
||||
assert.expect(2);
|
||||
var a = _.extend({}, Backbone.Events);
|
||||
var b = _.extend({}, Backbone.Events);
|
||||
var cb = function () { assert.ok(true); };
|
||||
var cb = function() { assert.ok(true); };
|
||||
a.listenTo(b, 'event', cb);
|
||||
b.on('event', cb);
|
||||
a.listenTo(b, 'event2', cb);
|
||||
@@ -158,10 +158,10 @@
|
||||
b.trigger('event2');
|
||||
});
|
||||
|
||||
QUnit.test("listenToOnce", function(assert) {
|
||||
QUnit.test('listenToOnce', function(assert) {
|
||||
assert.expect(2);
|
||||
// Same as the previous test, but we use once rather than having to explicitly unbind
|
||||
var obj = { counterA: 0, counterB: 0 };
|
||||
var obj = {counterA: 0, counterB: 0};
|
||||
_.extend(obj, Backbone.Events);
|
||||
var incrA = function(){ obj.counterA += 1; obj.trigger('event'); };
|
||||
var incrB = function(){ obj.counterB += 1; };
|
||||
@@ -172,7 +172,7 @@
|
||||
assert.equal(obj.counterB, 1, 'counterB should have only been incremented once.');
|
||||
});
|
||||
|
||||
QUnit.test("listenToOnce and stopListening", function(assert) {
|
||||
QUnit.test('listenToOnce and stopListening', function(assert) {
|
||||
assert.expect(1);
|
||||
var a = _.extend({}, Backbone.Events);
|
||||
var b = _.extend({}, Backbone.Events);
|
||||
@@ -184,7 +184,7 @@
|
||||
b.trigger('anything');
|
||||
});
|
||||
|
||||
QUnit.test("listenTo, listenToOnce and stopListening", function(assert) {
|
||||
QUnit.test('listenTo, listenToOnce and stopListening', function(assert) {
|
||||
assert.expect(1);
|
||||
var a = _.extend({}, Backbone.Events);
|
||||
var b = _.extend({}, Backbone.Events);
|
||||
@@ -196,7 +196,7 @@
|
||||
b.trigger('anything');
|
||||
});
|
||||
|
||||
QUnit.test("listenTo and stopListening with event maps", function(assert) {
|
||||
QUnit.test('listenTo and stopListening with event maps', function(assert) {
|
||||
assert.expect(1);
|
||||
var a = _.extend({}, Backbone.Events);
|
||||
var b = _.extend({}, Backbone.Events);
|
||||
@@ -207,23 +207,23 @@
|
||||
b.trigger('change');
|
||||
});
|
||||
|
||||
QUnit.test("listenTo yourself", function(assert) {
|
||||
QUnit.test('listenTo yourself', function(assert) {
|
||||
assert.expect(1);
|
||||
var e = _.extend({}, Backbone.Events);
|
||||
e.listenTo(e, "foo", function(){ assert.ok(true); });
|
||||
e.trigger("foo");
|
||||
e.listenTo(e, 'foo', function(){ assert.ok(true); });
|
||||
e.trigger('foo');
|
||||
});
|
||||
|
||||
QUnit.test("listenTo yourself cleans yourself up with stopListening", function(assert) {
|
||||
QUnit.test('listenTo yourself cleans yourself up with stopListening', function(assert) {
|
||||
assert.expect(1);
|
||||
var e = _.extend({}, Backbone.Events);
|
||||
e.listenTo(e, "foo", function(){ assert.ok(true); });
|
||||
e.trigger("foo");
|
||||
e.listenTo(e, 'foo', function(){ assert.ok(true); });
|
||||
e.trigger('foo');
|
||||
e.stopListening();
|
||||
e.trigger("foo");
|
||||
e.trigger('foo');
|
||||
});
|
||||
|
||||
QUnit.test("stopListening cleans up references", function(assert) {
|
||||
QUnit.test('stopListening cleans up references', function(assert) {
|
||||
assert.expect(12);
|
||||
var a = _.extend({}, Backbone.Events);
|
||||
var b = _.extend({}, Backbone.Events);
|
||||
@@ -247,7 +247,7 @@
|
||||
assert.equal(_.size(b._listeners), 0);
|
||||
});
|
||||
|
||||
QUnit.test("stopListening cleans up references from listenToOnce", function(assert) {
|
||||
QUnit.test('stopListening cleans up references from listenToOnce', function(assert) {
|
||||
assert.expect(12);
|
||||
var a = _.extend({}, Backbone.Events);
|
||||
var b = _.extend({}, Backbone.Events);
|
||||
@@ -271,7 +271,7 @@
|
||||
assert.equal(_.size(b._listeners), 0);
|
||||
});
|
||||
|
||||
QUnit.test("listenTo and off cleaning up references", function(assert) {
|
||||
QUnit.test('listenTo and off cleaning up references', function(assert) {
|
||||
assert.expect(8);
|
||||
var a = _.extend({}, Backbone.Events);
|
||||
var b = _.extend({}, Backbone.Events);
|
||||
@@ -294,7 +294,7 @@
|
||||
assert.equal(_.size(b._listeners), 0);
|
||||
});
|
||||
|
||||
QUnit.test("listenTo and stopListening cleaning up references", function(assert) {
|
||||
QUnit.test('listenTo and stopListening cleaning up references', function(assert) {
|
||||
assert.expect(2);
|
||||
var a = _.extend({}, Backbone.Events);
|
||||
var b = _.extend({}, Backbone.Events);
|
||||
@@ -306,7 +306,7 @@
|
||||
assert.equal(_.size(a._listeningTo), 0);
|
||||
});
|
||||
|
||||
QUnit.test("listenToOnce without context cleans up references after the event has fired", function(assert) {
|
||||
QUnit.test('listenToOnce without context cleans up references after the event has fired', function(assert) {
|
||||
assert.expect(2);
|
||||
var a = _.extend({}, Backbone.Events);
|
||||
var b = _.extend({}, Backbone.Events);
|
||||
@@ -315,7 +315,7 @@
|
||||
assert.equal(_.size(a._listeningTo), 0);
|
||||
});
|
||||
|
||||
QUnit.test("listenToOnce with event maps cleans up references", function(assert) {
|
||||
QUnit.test('listenToOnce with event maps cleans up references', function(assert) {
|
||||
assert.expect(2);
|
||||
var a = _.extend({}, Backbone.Events);
|
||||
var b = _.extend({}, Backbone.Events);
|
||||
@@ -327,7 +327,7 @@
|
||||
assert.equal(_.size(a._listeningTo), 1);
|
||||
});
|
||||
|
||||
QUnit.test("listenToOnce with event maps binds the correct `this`", function(assert) {
|
||||
QUnit.test('listenToOnce with event maps binds the correct `this`', function(assert) {
|
||||
assert.expect(1);
|
||||
var a = _.extend({}, Backbone.Events);
|
||||
var b = _.extend({}, Backbone.Events);
|
||||
@@ -341,14 +341,14 @@
|
||||
QUnit.test("listenTo with empty callback doesn't throw an error", function(assert) {
|
||||
assert.expect(1);
|
||||
var e = _.extend({}, Backbone.Events);
|
||||
e.listenTo(e, "foo", null);
|
||||
e.trigger("foo");
|
||||
e.listenTo(e, 'foo', null);
|
||||
e.trigger('foo');
|
||||
assert.ok(true);
|
||||
});
|
||||
|
||||
QUnit.test("trigger all for each event", function(assert) {
|
||||
QUnit.test('trigger all for each event', function(assert) {
|
||||
assert.expect(3);
|
||||
var a, b, obj = { counter: 0 };
|
||||
var a, b, obj = {counter: 0};
|
||||
_.extend(obj, Backbone.Events);
|
||||
obj.on('all', function(event) {
|
||||
obj.counter++;
|
||||
@@ -361,10 +361,10 @@
|
||||
assert.equal(obj.counter, 2);
|
||||
});
|
||||
|
||||
QUnit.test("on, then unbind all functions", function(assert) {
|
||||
QUnit.test('on, then unbind all functions', function(assert) {
|
||||
assert.expect(1);
|
||||
var obj = { counter: 0 };
|
||||
_.extend(obj,Backbone.Events);
|
||||
var obj = {counter: 0};
|
||||
_.extend(obj, Backbone.Events);
|
||||
var callback = function() { obj.counter += 1; };
|
||||
obj.on('event', callback);
|
||||
obj.trigger('event');
|
||||
@@ -373,10 +373,10 @@
|
||||
assert.equal(obj.counter, 1, 'counter should have only been incremented once.');
|
||||
});
|
||||
|
||||
QUnit.test("bind two callbacks, unbind only one", function(assert) {
|
||||
QUnit.test('bind two callbacks, unbind only one', function(assert) {
|
||||
assert.expect(2);
|
||||
var obj = { counterA: 0, counterB: 0 };
|
||||
_.extend(obj,Backbone.Events);
|
||||
var obj = {counterA: 0, counterB: 0};
|
||||
_.extend(obj, Backbone.Events);
|
||||
var callback = function() { obj.counterA += 1; };
|
||||
obj.on('event', callback);
|
||||
obj.on('event', function() { obj.counterB += 1; });
|
||||
@@ -387,7 +387,7 @@
|
||||
assert.equal(obj.counterB, 2, 'counterB should have been incremented twice.');
|
||||
});
|
||||
|
||||
QUnit.test("unbind a callback in the midst of it firing", function(assert) {
|
||||
QUnit.test('unbind a callback in the midst of it firing', function(assert) {
|
||||
assert.expect(1);
|
||||
var obj = {counter: 0};
|
||||
_.extend(obj, Backbone.Events);
|
||||
@@ -402,10 +402,10 @@
|
||||
assert.equal(obj.counter, 1, 'the callback should have been unbound.');
|
||||
});
|
||||
|
||||
QUnit.test("two binds that unbind themeselves", function(assert) {
|
||||
QUnit.test('two binds that unbind themeselves', function(assert) {
|
||||
assert.expect(2);
|
||||
var obj = { counterA: 0, counterB: 0 };
|
||||
_.extend(obj,Backbone.Events);
|
||||
var obj = {counterA: 0, counterB: 0};
|
||||
_.extend(obj, Backbone.Events);
|
||||
var incrA = function(){ obj.counterA += 1; obj.off('event', incrA); };
|
||||
var incrB = function(){ obj.counterB += 1; obj.off('event', incrB); };
|
||||
obj.on('event', incrA);
|
||||
@@ -417,23 +417,23 @@
|
||||
assert.equal(obj.counterB, 1, 'counterB should have only been incremented once.');
|
||||
});
|
||||
|
||||
QUnit.test("bind a callback with a supplied context", function(assert) {
|
||||
QUnit.test('bind a callback with a supplied context', function(assert) {
|
||||
assert.expect(1);
|
||||
var TestClass = function () {
|
||||
var TestClass = function() {
|
||||
return this;
|
||||
};
|
||||
TestClass.prototype.assertTrue = function () {
|
||||
TestClass.prototype.assertTrue = function() {
|
||||
assert.ok(true, '`this` was bound to the callback');
|
||||
};
|
||||
|
||||
var obj = _.extend({},Backbone.Events);
|
||||
obj.on('event', function () { this.assertTrue(); }, (new TestClass));
|
||||
var obj = _.extend({}, Backbone.Events);
|
||||
obj.on('event', function() { this.assertTrue(); }, new TestClass);
|
||||
obj.trigger('event');
|
||||
});
|
||||
|
||||
QUnit.test("nested trigger with unbind", function(assert) {
|
||||
QUnit.test('nested trigger with unbind', function(assert) {
|
||||
assert.expect(1);
|
||||
var obj = { counter: 0 };
|
||||
var obj = {counter: 0};
|
||||
_.extend(obj, Backbone.Events);
|
||||
var incr1 = function(){ obj.counter += 1; obj.off('event', incr1); obj.trigger('event'); };
|
||||
var incr2 = function(){ obj.counter += 1; };
|
||||
@@ -443,7 +443,7 @@
|
||||
assert.equal(obj.counter, 3, 'counter should have been incremented three times');
|
||||
});
|
||||
|
||||
QUnit.test("callback list is not altered during trigger", function(assert) {
|
||||
QUnit.test('callback list is not altered during trigger', function(assert) {
|
||||
assert.expect(2);
|
||||
var counter = 0, obj = _.extend({}, Backbone.Events);
|
||||
var incr = function(){ counter++; };
|
||||
@@ -469,12 +469,12 @@
|
||||
assert.strictEqual(counter, 2);
|
||||
});
|
||||
|
||||
QUnit.test("if no callback is provided, `on` is a noop", function(assert) {
|
||||
QUnit.test('if no callback is provided, `on` is a noop', function(assert) {
|
||||
assert.expect(0);
|
||||
_.extend({}, Backbone.Events).on('test').trigger('test');
|
||||
});
|
||||
|
||||
QUnit.test("if callback is truthy but not a function, `on` should throw an error just like jQuery", function(assert) {
|
||||
QUnit.test('if callback is truthy but not a function, `on` should throw an error just like jQuery', function(assert) {
|
||||
assert.expect(1);
|
||||
var view = _.extend({}, Backbone.Events).on('test', 'noop');
|
||||
assert.throws(function() {
|
||||
@@ -482,7 +482,7 @@
|
||||
});
|
||||
});
|
||||
|
||||
QUnit.test("remove all events for a specific context", function(assert) {
|
||||
QUnit.test('remove all events for a specific context', function(assert) {
|
||||
assert.expect(4);
|
||||
var obj = _.extend({}, Backbone.Events);
|
||||
obj.on('x y all', function() { assert.ok(true); });
|
||||
@@ -491,7 +491,7 @@
|
||||
obj.trigger('x y');
|
||||
});
|
||||
|
||||
QUnit.test("remove all events for a specific callback", function(assert) {
|
||||
QUnit.test('remove all events for a specific callback', function(assert) {
|
||||
assert.expect(4);
|
||||
var obj = _.extend({}, Backbone.Events);
|
||||
var success = function() { assert.ok(true); };
|
||||
@@ -502,7 +502,7 @@
|
||||
obj.trigger('x y');
|
||||
});
|
||||
|
||||
QUnit.test("#1310 - off does not skip consecutive events", function(assert) {
|
||||
QUnit.test('#1310 - off does not skip consecutive events', function(assert) {
|
||||
assert.expect(0);
|
||||
var obj = _.extend({}, Backbone.Events);
|
||||
obj.on('event', function() { assert.ok(false); }, obj);
|
||||
@@ -511,10 +511,10 @@
|
||||
obj.trigger('event');
|
||||
});
|
||||
|
||||
QUnit.test("once", function(assert) {
|
||||
QUnit.test('once', function(assert) {
|
||||
assert.expect(2);
|
||||
// Same as the previous test, but we use once rather than having to explicitly unbind
|
||||
var obj = { counterA: 0, counterB: 0 };
|
||||
var obj = {counterA: 0, counterB: 0};
|
||||
_.extend(obj, Backbone.Events);
|
||||
var incrA = function(){ obj.counterA += 1; obj.trigger('event'); };
|
||||
var incrB = function(){ obj.counterB += 1; };
|
||||
@@ -525,7 +525,7 @@
|
||||
assert.equal(obj.counterB, 1, 'counterB should have only been incremented once.');
|
||||
});
|
||||
|
||||
QUnit.test("once variant one", function(assert) {
|
||||
QUnit.test('once variant one', function(assert) {
|
||||
assert.expect(3);
|
||||
var f = function(){ assert.ok(true); };
|
||||
|
||||
@@ -538,7 +538,7 @@
|
||||
b.trigger('event');
|
||||
});
|
||||
|
||||
QUnit.test("once variant two", function(assert) {
|
||||
QUnit.test('once variant two', function(assert) {
|
||||
assert.expect(3);
|
||||
var f = function(){ assert.ok(true); };
|
||||
var obj = _.extend({}, Backbone.Events);
|
||||
@@ -550,7 +550,7 @@
|
||||
.trigger('event');
|
||||
});
|
||||
|
||||
QUnit.test("once with off", function(assert) {
|
||||
QUnit.test('once with off', function(assert) {
|
||||
assert.expect(0);
|
||||
var f = function(){ assert.ok(true); };
|
||||
var obj = _.extend({}, Backbone.Events);
|
||||
@@ -560,8 +560,8 @@
|
||||
obj.trigger('event');
|
||||
});
|
||||
|
||||
QUnit.test("once with event maps", function(assert) {
|
||||
var obj = { counter: 0 };
|
||||
QUnit.test('once with event maps', function(assert) {
|
||||
var obj = {counter: 0};
|
||||
_.extend(obj, Backbone.Events);
|
||||
|
||||
var increment = function() {
|
||||
@@ -587,7 +587,7 @@
|
||||
assert.equal(obj.counter, 3);
|
||||
});
|
||||
|
||||
QUnit.test("once with off only by context", function(assert) {
|
||||
QUnit.test('once with off only by context', function(assert) {
|
||||
assert.expect(0);
|
||||
var context = {};
|
||||
var obj = _.extend({}, Backbone.Events);
|
||||
@@ -596,11 +596,11 @@
|
||||
obj.trigger('event');
|
||||
});
|
||||
|
||||
QUnit.test("Backbone object inherits Events", function(assert) {
|
||||
QUnit.test('Backbone object inherits Events', function(assert) {
|
||||
assert.ok(Backbone.on === Backbone.Events.on);
|
||||
});
|
||||
|
||||
QUnit.test("once with asynchronous events", function(assert) {
|
||||
QUnit.test('once with asynchronous events', function(assert) {
|
||||
var done = assert.async();
|
||||
assert.expect(1);
|
||||
var func = _.debounce(function() { assert.ok(true); done(); }, 50);
|
||||
@@ -610,14 +610,14 @@
|
||||
obj.trigger('async');
|
||||
});
|
||||
|
||||
QUnit.test("once with multiple events.", function(assert) {
|
||||
QUnit.test('once with multiple events.', function(assert) {
|
||||
assert.expect(2);
|
||||
var obj = _.extend({}, Backbone.Events);
|
||||
obj.once('x y', function() { assert.ok(true); });
|
||||
obj.trigger('x y');
|
||||
});
|
||||
|
||||
QUnit.test("Off during iteration with once.", function(assert) {
|
||||
QUnit.test('Off during iteration with once.', function(assert) {
|
||||
assert.expect(2);
|
||||
var obj = _.extend({}, Backbone.Events);
|
||||
var f = function(){ this.off('event', f); };
|
||||
@@ -629,7 +629,7 @@
|
||||
obj.trigger('event');
|
||||
});
|
||||
|
||||
QUnit.test("`once` on `all` should work as expected", function(assert) {
|
||||
QUnit.test('`once` on `all` should work as expected', function(assert) {
|
||||
assert.expect(1);
|
||||
Backbone.once('all', function() {
|
||||
assert.ok(true);
|
||||
@@ -638,18 +638,18 @@
|
||||
Backbone.trigger('all');
|
||||
});
|
||||
|
||||
QUnit.test("once without a callback is a noop", function(assert) {
|
||||
QUnit.test('once without a callback is a noop', function(assert) {
|
||||
assert.expect(0);
|
||||
_.extend({}, Backbone.Events).once('event').trigger('event');
|
||||
});
|
||||
|
||||
QUnit.test("listenToOnce without a callback is a noop", function(assert) {
|
||||
QUnit.test('listenToOnce without a callback is a noop', function(assert) {
|
||||
assert.expect(0);
|
||||
var obj = _.extend({}, Backbone.Events);
|
||||
obj.listenToOnce(obj, 'event').trigger('event');
|
||||
});
|
||||
|
||||
QUnit.test("event functions are chainable", function(assert) {
|
||||
QUnit.test('event functions are chainable', function(assert) {
|
||||
var obj = _.extend({}, Backbone.Events);
|
||||
var obj2 = _.extend({}, Backbone.Events);
|
||||
var fn = function() {};
|
||||
@@ -666,7 +666,7 @@
|
||||
assert.equal(obj, obj.stopListening());
|
||||
});
|
||||
|
||||
QUnit.test("#3448 - listenToOnce with space-separated events", function(assert) {
|
||||
QUnit.test('#3448 - listenToOnce with space-separated events', function(assert) {
|
||||
assert.expect(2);
|
||||
var one = _.extend({}, Backbone.Events);
|
||||
var two = _.extend({}, Backbone.Events);
|
||||
|
||||
498
vendor/backbone/test/model.js
vendored
498
vendor/backbone/test/model.js
vendored
File diff suppressed because it is too large
Load Diff
2
vendor/backbone/test/noconflict.js
vendored
2
vendor/backbone/test/noconflict.js
vendored
@@ -1,6 +1,6 @@
|
||||
(function() {
|
||||
|
||||
QUnit.module("Backbone.noConflict");
|
||||
QUnit.module('Backbone.noConflict');
|
||||
|
||||
QUnit.test('noConflict', function(assert) {
|
||||
assert.expect(2);
|
||||
|
||||
158
vendor/backbone/test/router.js
vendored
158
vendor/backbone/test/router.js
vendored
@@ -40,7 +40,7 @@
|
||||
|
||||
});
|
||||
|
||||
QUnit.module("Backbone.Router", {
|
||||
QUnit.module('Backbone.Router', {
|
||||
|
||||
setup: function() {
|
||||
location = new Location('http://example.com');
|
||||
@@ -74,28 +74,28 @@
|
||||
count: 0,
|
||||
|
||||
routes: {
|
||||
"noCallback": "noCallback",
|
||||
"counter": "counter",
|
||||
"search/:query": "search",
|
||||
"search/:query/p:page": "search",
|
||||
"charñ": "charUTF",
|
||||
"char%C3%B1": "charEscaped",
|
||||
"contacts": "contacts",
|
||||
"contacts/new": "newContact",
|
||||
"contacts/:id": "loadContact",
|
||||
"route-event/:arg": "routeEvent",
|
||||
"optional(/:item)": "optionalItem",
|
||||
"named/optional/(y:z)": "namedOptional",
|
||||
"splat/*args/end": "splat",
|
||||
":repo/compare/*from...*to": "github",
|
||||
"decode/:named/*splat": "decode",
|
||||
"*first/complex-*part/*rest": "complex",
|
||||
"query/:entity": "query",
|
||||
"function/:value": ExternalObject.routingFunction,
|
||||
"*anything": "anything"
|
||||
'noCallback': 'noCallback',
|
||||
'counter': 'counter',
|
||||
'search/:query': 'search',
|
||||
'search/:query/p:page': 'search',
|
||||
'charñ': 'charUTF',
|
||||
'char%C3%B1': 'charEscaped',
|
||||
'contacts': 'contacts',
|
||||
'contacts/new': 'newContact',
|
||||
'contacts/:id': 'loadContact',
|
||||
'route-event/:arg': 'routeEvent',
|
||||
'optional(/:item)': 'optionalItem',
|
||||
'named/optional/(y:z)': 'namedOptional',
|
||||
'splat/*args/end': 'splat',
|
||||
':repo/compare/*from...*to': 'github',
|
||||
'decode/:named/*splat': 'decode',
|
||||
'*first/complex-*part/*rest': 'complex',
|
||||
'query/:entity': 'query',
|
||||
'function/:value': ExternalObject.routingFunction,
|
||||
'*anything': 'anything'
|
||||
},
|
||||
|
||||
initialize : function(options) {
|
||||
initialize: function(options) {
|
||||
this.testing = options.testing;
|
||||
this.route('implicit', 'implicit');
|
||||
},
|
||||
@@ -176,12 +176,12 @@
|
||||
|
||||
});
|
||||
|
||||
QUnit.test("initialize", function(assert) {
|
||||
QUnit.test('initialize', function(assert) {
|
||||
assert.expect(1);
|
||||
assert.equal(router.testing, 101);
|
||||
});
|
||||
|
||||
QUnit.test("routes (simple)", function(assert) {
|
||||
QUnit.test('routes (simple)', function(assert) {
|
||||
assert.expect(4);
|
||||
location.replace('http://example.com#search/news');
|
||||
Backbone.history.checkUrl();
|
||||
@@ -191,17 +191,17 @@
|
||||
assert.equal(lastArgs[0], 'news');
|
||||
});
|
||||
|
||||
QUnit.test("routes (simple, but unicode)", function(assert) {
|
||||
QUnit.test('routes (simple, but unicode)', function(assert) {
|
||||
assert.expect(4);
|
||||
location.replace('http://example.com#search/тест');
|
||||
Backbone.history.checkUrl();
|
||||
assert.equal(router.query, "тест");
|
||||
assert.equal(router.query, 'тест');
|
||||
assert.equal(router.page, void 0);
|
||||
assert.equal(lastRoute, 'search');
|
||||
assert.equal(lastArgs[0], "тест");
|
||||
assert.equal(lastArgs[0], 'тест');
|
||||
});
|
||||
|
||||
QUnit.test("routes (two part)", function(assert) {
|
||||
QUnit.test('routes (two part)', function(assert) {
|
||||
assert.expect(2);
|
||||
location.replace('http://example.com#search/nyc/p10');
|
||||
Backbone.history.checkUrl();
|
||||
@@ -209,35 +209,35 @@
|
||||
assert.equal(router.page, '10');
|
||||
});
|
||||
|
||||
QUnit.test("routes via navigate", function(assert) {
|
||||
QUnit.test('routes via navigate', function(assert) {
|
||||
assert.expect(2);
|
||||
Backbone.history.navigate('search/manhattan/p20', {trigger: true});
|
||||
assert.equal(router.query, 'manhattan');
|
||||
assert.equal(router.page, '20');
|
||||
});
|
||||
|
||||
QUnit.test("routes via navigate with params", function(assert) {
|
||||
QUnit.test('routes via navigate with params', function(assert) {
|
||||
assert.expect(1);
|
||||
Backbone.history.navigate('query/test?a=b', {trigger: true});
|
||||
assert.equal(router.queryArgs, 'a=b');
|
||||
});
|
||||
|
||||
QUnit.test("routes via navigate for backwards-compatibility", function(assert) {
|
||||
QUnit.test('routes via navigate for backwards-compatibility', function(assert) {
|
||||
assert.expect(2);
|
||||
Backbone.history.navigate('search/manhattan/p20', true);
|
||||
assert.equal(router.query, 'manhattan');
|
||||
assert.equal(router.page, '20');
|
||||
});
|
||||
|
||||
QUnit.test("reports matched route via nagivate", function(assert) {
|
||||
QUnit.test('reports matched route via nagivate', function(assert) {
|
||||
assert.expect(1);
|
||||
assert.ok(Backbone.history.navigate('search/manhattan/p20', true));
|
||||
});
|
||||
|
||||
QUnit.test("route precedence via navigate", function(assert){
|
||||
QUnit.test('route precedence via navigate', function(assert){
|
||||
assert.expect(6);
|
||||
// check both 0.9.x and backwards-compatibility options
|
||||
_.each([ { trigger: true }, true ], function( options ){
|
||||
_.each([{trigger: true}, true], function( options ){
|
||||
Backbone.history.navigate('contacts', options);
|
||||
assert.equal(router.contact, 'index');
|
||||
Backbone.history.navigate('contacts/new', options);
|
||||
@@ -247,7 +247,7 @@
|
||||
});
|
||||
});
|
||||
|
||||
QUnit.test("loadUrl is not called for identical routes.", function(assert) {
|
||||
QUnit.test('loadUrl is not called for identical routes.', function(assert) {
|
||||
assert.expect(0);
|
||||
Backbone.history.loadUrl = function(){ assert.ok(false); };
|
||||
location.replace('http://example.com#route');
|
||||
@@ -256,14 +256,14 @@
|
||||
Backbone.history.navigate('/route');
|
||||
});
|
||||
|
||||
QUnit.test("use implicit callback if none provided", function(assert) {
|
||||
QUnit.test('use implicit callback if none provided', function(assert) {
|
||||
assert.expect(1);
|
||||
router.count = 0;
|
||||
router.navigate('implicit', {trigger: true});
|
||||
assert.equal(router.count, 1);
|
||||
});
|
||||
|
||||
QUnit.test("routes via navigate with {replace: true}", function(assert) {
|
||||
QUnit.test('routes via navigate with {replace: true}', function(assert) {
|
||||
assert.expect(1);
|
||||
location.replace('http://example.com#start_here');
|
||||
Backbone.history.checkUrl();
|
||||
@@ -273,14 +273,14 @@
|
||||
Backbone.history.navigate('end_here', {replace: true});
|
||||
});
|
||||
|
||||
QUnit.test("routes (splats)", function(assert) {
|
||||
QUnit.test('routes (splats)', function(assert) {
|
||||
assert.expect(1);
|
||||
location.replace('http://example.com#splat/long-list/of/splatted_99args/end');
|
||||
Backbone.history.checkUrl();
|
||||
assert.equal(router.args, 'long-list/of/splatted_99args');
|
||||
});
|
||||
|
||||
QUnit.test("routes (github)", function(assert) {
|
||||
QUnit.test('routes (github)', function(assert) {
|
||||
assert.expect(3);
|
||||
location.replace('http://example.com#backbone/compare/1.0...braddunbar:with/slash');
|
||||
Backbone.history.checkUrl();
|
||||
@@ -289,7 +289,7 @@
|
||||
assert.equal(router.to, 'braddunbar:with/slash');
|
||||
});
|
||||
|
||||
QUnit.test("routes (optional)", function(assert) {
|
||||
QUnit.test('routes (optional)', function(assert) {
|
||||
assert.expect(2);
|
||||
location.replace('http://example.com#optional');
|
||||
Backbone.history.checkUrl();
|
||||
@@ -299,7 +299,7 @@
|
||||
assert.equal(router.arg, 'thing');
|
||||
});
|
||||
|
||||
QUnit.test("routes (complex)", function(assert) {
|
||||
QUnit.test('routes (complex)', function(assert) {
|
||||
assert.expect(3);
|
||||
location.replace('http://example.com#one/two/three/complex-part/four/five/six/seven');
|
||||
Backbone.history.checkUrl();
|
||||
@@ -308,7 +308,7 @@
|
||||
assert.equal(router.rest, 'four/five/six/seven');
|
||||
});
|
||||
|
||||
QUnit.test("routes (query)", function(assert) {
|
||||
QUnit.test('routes (query)', function(assert) {
|
||||
assert.expect(5);
|
||||
location.replace('http://example.com#query/mandel?a=b&c=d');
|
||||
Backbone.history.checkUrl();
|
||||
@@ -319,14 +319,14 @@
|
||||
assert.equal(lastArgs[1], 'a=b&c=d');
|
||||
});
|
||||
|
||||
QUnit.test("routes (anything)", function(assert) {
|
||||
QUnit.test('routes (anything)', function(assert) {
|
||||
assert.expect(1);
|
||||
location.replace('http://example.com#doesnt-match-a-route');
|
||||
Backbone.history.checkUrl();
|
||||
assert.equal(router.anything, 'doesnt-match-a-route');
|
||||
});
|
||||
|
||||
QUnit.test("routes (function)", function(assert) {
|
||||
QUnit.test('routes (function)', function(assert) {
|
||||
assert.expect(3);
|
||||
router.on('route', function(name) {
|
||||
assert.ok(name === '');
|
||||
@@ -337,7 +337,7 @@
|
||||
assert.equal(ExternalObject.value, 'set');
|
||||
});
|
||||
|
||||
QUnit.test("Decode named parameters, not splats.", function(assert) {
|
||||
QUnit.test('Decode named parameters, not splats.', function(assert) {
|
||||
assert.expect(2);
|
||||
location.replace('http://example.com#decode/a%2Fb/c%2Fd/e');
|
||||
Backbone.history.checkUrl();
|
||||
@@ -347,12 +347,12 @@
|
||||
|
||||
QUnit.test("fires event when router doesn't have callback on it", function(assert) {
|
||||
assert.expect(1);
|
||||
router.on("route:noCallback", function(){ assert.ok(true); });
|
||||
router.on('route:noCallback', function(){ assert.ok(true); });
|
||||
location.replace('http://example.com#noCallback');
|
||||
Backbone.history.checkUrl();
|
||||
});
|
||||
|
||||
QUnit.test("No events are triggered if #execute returns false.", function(assert) {
|
||||
QUnit.test('No events are triggered if #execute returns false.', function(assert) {
|
||||
assert.expect(1);
|
||||
var Router = Backbone.Router.extend({
|
||||
|
||||
@@ -383,7 +383,7 @@
|
||||
Backbone.history.checkUrl();
|
||||
});
|
||||
|
||||
QUnit.test("#933, #908 - leading slash", function(assert) {
|
||||
QUnit.test('#933, #908 - leading slash', function(assert) {
|
||||
assert.expect(2);
|
||||
location.replace('http://example.com/root/foo');
|
||||
|
||||
@@ -398,7 +398,7 @@
|
||||
assert.strictEqual(Backbone.history.getFragment(), 'foo');
|
||||
});
|
||||
|
||||
QUnit.test("#967 - Route callback gets passed encoded values.", function(assert) {
|
||||
QUnit.test('#967 - Route callback gets passed encoded values.', function(assert) {
|
||||
assert.expect(3);
|
||||
var route = 'has%2Fslash/complex-has%23hash/has%20space';
|
||||
Backbone.history.navigate(route, {trigger: true});
|
||||
@@ -407,7 +407,7 @@
|
||||
assert.strictEqual(router.rest, 'has space');
|
||||
});
|
||||
|
||||
QUnit.test("correctly handles URLs with % (#868)", function(assert) {
|
||||
QUnit.test('correctly handles URLs with % (#868)', function(assert) {
|
||||
assert.expect(3);
|
||||
location.replace('http://example.com#search/fat%3A1.5%25');
|
||||
Backbone.history.checkUrl();
|
||||
@@ -418,7 +418,7 @@
|
||||
assert.equal(lastRoute, 'search');
|
||||
});
|
||||
|
||||
QUnit.test("#2666 - Hashes with UTF8 in them.", function(assert) {
|
||||
QUnit.test('#2666 - Hashes with UTF8 in them.', function(assert) {
|
||||
assert.expect(2);
|
||||
Backbone.history.navigate('charñ', {trigger: true});
|
||||
assert.equal(router.charType, 'UTF');
|
||||
@@ -426,7 +426,7 @@
|
||||
assert.equal(router.charType, 'UTF');
|
||||
});
|
||||
|
||||
QUnit.test("#1185 - Use pathname when hashChange is not wanted.", function(assert) {
|
||||
QUnit.test('#1185 - Use pathname when hashChange is not wanted.', function(assert) {
|
||||
assert.expect(1);
|
||||
Backbone.history.stop();
|
||||
location.replace('http://example.com/path/name#hash');
|
||||
@@ -436,7 +436,7 @@
|
||||
assert.strictEqual(fragment, location.pathname.replace(/^\//, ''));
|
||||
});
|
||||
|
||||
QUnit.test("#1206 - Strip leading slash before location.assign.", function(assert) {
|
||||
QUnit.test('#1206 - Strip leading slash before location.assign.', function(assert) {
|
||||
assert.expect(1);
|
||||
Backbone.history.stop();
|
||||
location.replace('http://example.com/root/');
|
||||
@@ -448,7 +448,7 @@
|
||||
Backbone.history.navigate('/fragment');
|
||||
});
|
||||
|
||||
QUnit.test("#1387 - Root fragment without trailing slash.", function(assert) {
|
||||
QUnit.test('#1387 - Root fragment without trailing slash.', function(assert) {
|
||||
assert.expect(1);
|
||||
Backbone.history.stop();
|
||||
location.replace('http://example.com/root');
|
||||
@@ -457,7 +457,7 @@
|
||||
assert.strictEqual(Backbone.history.getFragment(), '');
|
||||
});
|
||||
|
||||
QUnit.test("#1366 - History does not prepend root to fragment.", function(assert) {
|
||||
QUnit.test('#1366 - History does not prepend root to fragment.', function(assert) {
|
||||
assert.expect(2);
|
||||
Backbone.history.stop();
|
||||
location.replace('http://example.com/root/');
|
||||
@@ -478,7 +478,7 @@
|
||||
assert.strictEqual(Backbone.history.fragment, 'x');
|
||||
});
|
||||
|
||||
QUnit.test("Normalize root.", function(assert) {
|
||||
QUnit.test('Normalize root.', function(assert) {
|
||||
assert.expect(1);
|
||||
Backbone.history.stop();
|
||||
location.replace('http://example.com/root');
|
||||
@@ -498,7 +498,7 @@
|
||||
Backbone.history.navigate('fragment');
|
||||
});
|
||||
|
||||
QUnit.test("Normalize root.", function(assert) {
|
||||
QUnit.test('Normalize root.', function(assert) {
|
||||
assert.expect(1);
|
||||
Backbone.history.stop();
|
||||
location.replace('http://example.com/root#fragment');
|
||||
@@ -517,7 +517,7 @@
|
||||
});
|
||||
});
|
||||
|
||||
QUnit.test("Normalize root.", function(assert) {
|
||||
QUnit.test('Normalize root.', function(assert) {
|
||||
assert.expect(1);
|
||||
Backbone.history.stop();
|
||||
location.replace('http://example.com/root');
|
||||
@@ -529,7 +529,7 @@
|
||||
});
|
||||
});
|
||||
|
||||
QUnit.test("Normalize root - leading slash.", function(assert) {
|
||||
QUnit.test('Normalize root - leading slash.', function(assert) {
|
||||
assert.expect(1);
|
||||
Backbone.history.stop();
|
||||
location.replace('http://example.com/root');
|
||||
@@ -544,7 +544,7 @@
|
||||
assert.strictEqual(Backbone.history.root, '/root/');
|
||||
});
|
||||
|
||||
QUnit.test("Transition from hashChange to pushState.", function(assert) {
|
||||
QUnit.test('Transition from hashChange to pushState.', function(assert) {
|
||||
assert.expect(1);
|
||||
Backbone.history.stop();
|
||||
location.replace('http://example.com/root#x/y');
|
||||
@@ -563,7 +563,7 @@
|
||||
});
|
||||
});
|
||||
|
||||
QUnit.test("#1619: Router: Normalize empty root", function(assert) {
|
||||
QUnit.test('#1619: Router: Normalize empty root', function(assert) {
|
||||
assert.expect(1);
|
||||
Backbone.history.stop();
|
||||
location.replace('http://example.com/');
|
||||
@@ -578,7 +578,7 @@
|
||||
assert.strictEqual(Backbone.history.root, '/');
|
||||
});
|
||||
|
||||
QUnit.test("#1619: Router: nagivate with empty root", function(assert) {
|
||||
QUnit.test('#1619: Router: nagivate with empty root', function(assert) {
|
||||
assert.expect(1);
|
||||
Backbone.history.stop();
|
||||
location.replace('http://example.com/');
|
||||
@@ -598,7 +598,7 @@
|
||||
Backbone.history.navigate('fragment');
|
||||
});
|
||||
|
||||
QUnit.test("Transition from pushState to hashChange.", function(assert) {
|
||||
QUnit.test('Transition from pushState to hashChange.', function(assert) {
|
||||
assert.expect(1);
|
||||
Backbone.history.stop();
|
||||
location.replace('http://example.com/root/x/y?a=b');
|
||||
@@ -618,7 +618,7 @@
|
||||
});
|
||||
});
|
||||
|
||||
QUnit.test("#1695 - hashChange to pushState with search.", function(assert) {
|
||||
QUnit.test('#1695 - hashChange to pushState with search.', function(assert) {
|
||||
assert.expect(1);
|
||||
Backbone.history.stop();
|
||||
location.replace('http://example.com/root#x/y?a=b');
|
||||
@@ -637,7 +637,7 @@
|
||||
});
|
||||
});
|
||||
|
||||
QUnit.test("#1746 - Router allows empty route.", function(assert) {
|
||||
QUnit.test('#1746 - Router allows empty route.', function(assert) {
|
||||
assert.expect(1);
|
||||
var Router = Backbone.Router.extend({
|
||||
routes: {'': 'empty'},
|
||||
@@ -649,18 +649,18 @@
|
||||
new Router;
|
||||
});
|
||||
|
||||
QUnit.test("#1794 - Trailing space in fragments.", function(assert) {
|
||||
QUnit.test('#1794 - Trailing space in fragments.', function(assert) {
|
||||
assert.expect(1);
|
||||
var history = new Backbone.History;
|
||||
assert.strictEqual(history.getFragment('fragment '), 'fragment');
|
||||
});
|
||||
|
||||
QUnit.test("#1820 - Leading slash and trailing space.", 1, function(assert) {
|
||||
QUnit.test('#1820 - Leading slash and trailing space.', 1, function(assert) {
|
||||
var history = new Backbone.History;
|
||||
assert.strictEqual(history.getFragment('/fragment '), 'fragment');
|
||||
});
|
||||
|
||||
QUnit.test("#1980 - Optional parameters.", function(assert) {
|
||||
QUnit.test('#1980 - Optional parameters.', function(assert) {
|
||||
assert.expect(2);
|
||||
location.replace('http://example.com#named/optional/y');
|
||||
Backbone.history.checkUrl();
|
||||
@@ -680,13 +680,13 @@
|
||||
Backbone.history.checkUrl();
|
||||
});
|
||||
|
||||
QUnit.test("#2255 - Extend routes by making routes a function.", function(assert) {
|
||||
QUnit.test('#2255 - Extend routes by making routes a function.', function(assert) {
|
||||
assert.expect(1);
|
||||
var RouterBase = Backbone.Router.extend({
|
||||
routes: function() {
|
||||
return {
|
||||
home: "root",
|
||||
index: "index.html"
|
||||
home: 'root',
|
||||
index: 'index.html'
|
||||
};
|
||||
}
|
||||
});
|
||||
@@ -694,17 +694,15 @@
|
||||
var RouterExtended = RouterBase.extend({
|
||||
routes: function() {
|
||||
var _super = RouterExtended.__super__.routes;
|
||||
return _.extend(_super(),
|
||||
{ show: "show",
|
||||
search: "search" });
|
||||
return _.extend(_super(), {show: 'show', search: 'search'});
|
||||
}
|
||||
});
|
||||
|
||||
var router = new RouterExtended();
|
||||
assert.deepEqual({home: "root", index: "index.html", show: "show", search: "search"}, router.routes);
|
||||
assert.deepEqual({home: 'root', index: 'index.html', show: 'show', search: 'search'}, router.routes);
|
||||
});
|
||||
|
||||
QUnit.test("#2538 - hashChange to pushState only if both requested.", function(assert) {
|
||||
QUnit.test('#2538 - hashChange to pushState only if both requested.', function(assert) {
|
||||
assert.expect(0);
|
||||
Backbone.history.stop();
|
||||
location.replace('http://example.com/root?a=b#x/y');
|
||||
@@ -934,7 +932,7 @@
|
||||
Backbone.history.start();
|
||||
});
|
||||
|
||||
QUnit.test("pushState to hashChange with only search params.", function(assert) {
|
||||
QUnit.test('pushState to hashChange with only search params.', function(assert) {
|
||||
assert.expect(1);
|
||||
Backbone.history.stop();
|
||||
location.replace('http://example.com?a=b');
|
||||
@@ -948,7 +946,7 @@
|
||||
Backbone.history.start({pushState: true});
|
||||
});
|
||||
|
||||
QUnit.test("#3123 - History#navigate decodes before comparison.", function(assert) {
|
||||
QUnit.test('#3123 - History#navigate decodes before comparison.', function(assert) {
|
||||
assert.expect(1);
|
||||
Backbone.history.stop();
|
||||
location.replace('http://example.com/shop/search?keyword=short%20dress');
|
||||
@@ -1025,7 +1023,7 @@
|
||||
Backbone.history.start({root: 'root', pushState: true});
|
||||
});
|
||||
|
||||
QUnit.test("roots with regex characters", function(assert) {
|
||||
QUnit.test('roots with regex characters', function(assert) {
|
||||
assert.expect(1);
|
||||
location.replace('http://example.com/x+y.z/foo');
|
||||
Backbone.history.stop();
|
||||
@@ -1037,7 +1035,7 @@
|
||||
Backbone.history.start({root: 'x+y.z', pushState: true});
|
||||
});
|
||||
|
||||
QUnit.test("roots with unicode characters", function(assert) {
|
||||
QUnit.test('roots with unicode characters', function(assert) {
|
||||
assert.expect(1);
|
||||
location.replace('http://example.com/®ooτ/foo');
|
||||
Backbone.history.stop();
|
||||
@@ -1049,7 +1047,7 @@
|
||||
Backbone.history.start({root: '®ooτ', pushState: true});
|
||||
});
|
||||
|
||||
QUnit.test("roots without slash", function(assert) {
|
||||
QUnit.test('roots without slash', function(assert) {
|
||||
assert.expect(1);
|
||||
location.replace('http://example.com/®ooτ');
|
||||
Backbone.history.stop();
|
||||
|
||||
42
vendor/backbone/test/sync.js
vendored
42
vendor/backbone/test/sync.js
vendored
@@ -1,19 +1,19 @@
|
||||
(function() {
|
||||
|
||||
var Library = Backbone.Collection.extend({
|
||||
url : function() { return '/library'; }
|
||||
url: function() { return '/library'; }
|
||||
});
|
||||
var library;
|
||||
|
||||
var attrs = {
|
||||
title : "The Tempest",
|
||||
author : "Bill Shakespeare",
|
||||
length : 123
|
||||
title: 'The Tempest',
|
||||
author: 'Bill Shakespeare',
|
||||
length: 123
|
||||
};
|
||||
|
||||
QUnit.module("Backbone.sync", {
|
||||
QUnit.module('Backbone.sync', {
|
||||
|
||||
beforeEach : function(assert) {
|
||||
beforeEach: function(assert) {
|
||||
library = new Library;
|
||||
library.create(attrs, {wait: false});
|
||||
},
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
});
|
||||
|
||||
QUnit.test("read", function(assert) {
|
||||
QUnit.test('read', function(assert) {
|
||||
assert.expect(4);
|
||||
library.fetch();
|
||||
assert.equal(this.ajaxSettings.url, '/library');
|
||||
@@ -33,7 +33,7 @@
|
||||
assert.ok(_.isEmpty(this.ajaxSettings.data));
|
||||
});
|
||||
|
||||
QUnit.test("passing data", function(assert) {
|
||||
QUnit.test('passing data', function(assert) {
|
||||
assert.expect(3);
|
||||
library.fetch({data: {a: 'a', one: 1}});
|
||||
assert.equal(this.ajaxSettings.url, '/library');
|
||||
@@ -41,7 +41,7 @@
|
||||
assert.equal(this.ajaxSettings.data.one, 1);
|
||||
});
|
||||
|
||||
QUnit.test("create", function(assert) {
|
||||
QUnit.test('create', function(assert) {
|
||||
assert.expect(6);
|
||||
assert.equal(this.ajaxSettings.url, '/library');
|
||||
assert.equal(this.ajaxSettings.type, 'POST');
|
||||
@@ -52,7 +52,7 @@
|
||||
assert.equal(data.length, 123);
|
||||
});
|
||||
|
||||
QUnit.test("update", function(assert) {
|
||||
QUnit.test('update', function(assert) {
|
||||
assert.expect(7);
|
||||
library.first().save({id: '1-the-tempest', author: 'William Shakespeare'});
|
||||
assert.equal(this.ajaxSettings.url, '/library/1-the-tempest');
|
||||
@@ -65,7 +65,7 @@
|
||||
assert.equal(data.length, 123);
|
||||
});
|
||||
|
||||
QUnit.test("update with emulateHTTP and emulateJSON", function(assert) {
|
||||
QUnit.test('update with emulateHTTP and emulateJSON', function(assert) {
|
||||
assert.expect(7);
|
||||
library.first().save({id: '2-the-tempest', author: 'Tim Shakespeare'}, {
|
||||
emulateHTTP: true,
|
||||
@@ -81,7 +81,7 @@
|
||||
assert.equal(data.length, 123);
|
||||
});
|
||||
|
||||
QUnit.test("update with just emulateHTTP", function(assert) {
|
||||
QUnit.test('update with just emulateHTTP', function(assert) {
|
||||
assert.expect(6);
|
||||
library.first().save({id: '2-the-tempest', author: 'Tim Shakespeare'}, {
|
||||
emulateHTTP: true
|
||||
@@ -95,7 +95,7 @@
|
||||
assert.equal(data.length, 123);
|
||||
});
|
||||
|
||||
QUnit.test("update with just emulateJSON", function(assert) {
|
||||
QUnit.test('update with just emulateJSON', function(assert) {
|
||||
assert.expect(6);
|
||||
library.first().save({id: '2-the-tempest', author: 'Tim Shakespeare'}, {
|
||||
emulateJSON: true
|
||||
@@ -109,7 +109,7 @@
|
||||
assert.equal(data.length, 123);
|
||||
});
|
||||
|
||||
QUnit.test("read model", function(assert) {
|
||||
QUnit.test('read model', function(assert) {
|
||||
assert.expect(3);
|
||||
library.first().save({id: '2-the-tempest', author: 'Tim Shakespeare'});
|
||||
library.first().fetch();
|
||||
@@ -118,7 +118,7 @@
|
||||
assert.ok(_.isEmpty(this.ajaxSettings.data));
|
||||
});
|
||||
|
||||
QUnit.test("destroy", function(assert) {
|
||||
QUnit.test('destroy', function(assert) {
|
||||
assert.expect(3);
|
||||
library.first().save({id: '2-the-tempest', author: 'Tim Shakespeare'});
|
||||
library.first().destroy({wait: true});
|
||||
@@ -127,7 +127,7 @@
|
||||
assert.equal(this.ajaxSettings.data, null);
|
||||
});
|
||||
|
||||
QUnit.test("destroy with emulateHTTP", function(assert) {
|
||||
QUnit.test('destroy with emulateHTTP', function(assert) {
|
||||
assert.expect(3);
|
||||
library.first().save({id: '2-the-tempest', author: 'Tim Shakespeare'});
|
||||
library.first().destroy({
|
||||
@@ -139,7 +139,7 @@
|
||||
assert.equal(JSON.stringify(this.ajaxSettings.data), '{"_method":"DELETE"}');
|
||||
});
|
||||
|
||||
QUnit.test("urlError", function(assert) {
|
||||
QUnit.test('urlError', function(assert) {
|
||||
assert.expect(2);
|
||||
var model = new Backbone.Model();
|
||||
assert.throws(function() {
|
||||
@@ -149,14 +149,14 @@
|
||||
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);
|
||||
var model = new Backbone.Model();
|
||||
model.url = '/test';
|
||||
Backbone.sync('create', model);
|
||||
});
|
||||
|
||||
QUnit.test("Backbone.ajax", function(assert) {
|
||||
QUnit.test('Backbone.ajax', function(assert) {
|
||||
assert.expect(1);
|
||||
Backbone.ajax = function(settings){
|
||||
assert.strictEqual(settings.url, '/test');
|
||||
@@ -166,7 +166,7 @@
|
||||
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);
|
||||
var model = new Backbone.Model;
|
||||
model.url = '/test';
|
||||
@@ -204,7 +204,7 @@
|
||||
assert.strictEqual(this.ajaxSettings.emulateJSON, false);
|
||||
});
|
||||
|
||||
QUnit.test("#1756 - Call user provided beforeSend function.", function(assert) {
|
||||
QUnit.test('#1756 - Call user provided beforeSend function.', function(assert) {
|
||||
assert.expect(4);
|
||||
Backbone.emulateHTTP = true;
|
||||
var model = new Backbone.Model;
|
||||
|
||||
92
vendor/backbone/test/view.js
vendored
92
vendor/backbone/test/view.js
vendored
@@ -2,7 +2,7 @@
|
||||
|
||||
var view;
|
||||
|
||||
QUnit.module("Backbone.View", {
|
||||
QUnit.module('Backbone.View', {
|
||||
|
||||
beforeEach: function(assert) {
|
||||
$('#qunit-fixture').append(
|
||||
@@ -10,22 +10,22 @@
|
||||
);
|
||||
|
||||
view = new Backbone.View({
|
||||
id : 'test-view',
|
||||
className : 'test-view',
|
||||
other : 'non-special-option'
|
||||
id: 'test-view',
|
||||
className: 'test-view',
|
||||
other: 'non-special-option'
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
QUnit.test("constructor", function(assert) {
|
||||
QUnit.test('constructor', function(assert) {
|
||||
assert.expect(3);
|
||||
assert.equal(view.el.id, 'test-view');
|
||||
assert.equal(view.el.className, 'test-view');
|
||||
assert.equal(view.el.other, void 0);
|
||||
});
|
||||
|
||||
QUnit.test("$", function(assert) {
|
||||
QUnit.test('$', function(assert) {
|
||||
assert.expect(2);
|
||||
var view = new Backbone.View;
|
||||
view.setElement('<p><a><b>test</b></a></p>');
|
||||
@@ -35,7 +35,7 @@
|
||||
assert.ok(result.length === +result.length);
|
||||
});
|
||||
|
||||
QUnit.test("$el", function(assert) {
|
||||
QUnit.test('$el', function(assert) {
|
||||
assert.expect(3);
|
||||
var view = new Backbone.View;
|
||||
view.setElement('<p><a><b>test</b></a></p>');
|
||||
@@ -45,7 +45,7 @@
|
||||
assert.strictEqual(view.$el[0], view.el);
|
||||
});
|
||||
|
||||
QUnit.test("initialize", function(assert) {
|
||||
QUnit.test('initialize', function(assert) {
|
||||
assert.expect(1);
|
||||
var View = Backbone.View.extend({
|
||||
initialize: function() {
|
||||
@@ -56,13 +56,13 @@
|
||||
assert.strictEqual(new View().one, 1);
|
||||
});
|
||||
|
||||
QUnit.test("render", function(assert) {
|
||||
QUnit.test('render', function(assert) {
|
||||
assert.expect(1);
|
||||
var view = new Backbone.View;
|
||||
assert.equal(view.render(), view, '#render returns the view instance');
|
||||
});
|
||||
|
||||
QUnit.test("delegateEvents", function(assert) {
|
||||
QUnit.test('delegateEvents', function(assert) {
|
||||
assert.expect(6);
|
||||
var counter1 = 0, counter2 = 0;
|
||||
|
||||
@@ -87,7 +87,7 @@
|
||||
assert.equal(counter2, 3);
|
||||
});
|
||||
|
||||
QUnit.test("delegate", function(assert) {
|
||||
QUnit.test('delegate', function(assert) {
|
||||
assert.expect(3);
|
||||
var view = new Backbone.View({el: '#testElement'});
|
||||
view.delegate('click', 'h1', function() {
|
||||
@@ -101,7 +101,7 @@
|
||||
assert.equal(view.delegate(), view, '#delegate returns the view instance');
|
||||
});
|
||||
|
||||
QUnit.test("delegateEvents allows functions for callbacks", function(assert) {
|
||||
QUnit.test('delegateEvents allows functions for callbacks', function(assert) {
|
||||
assert.expect(3);
|
||||
var view = new Backbone.View({el: '<p></p>'});
|
||||
view.counter = 0;
|
||||
@@ -125,14 +125,14 @@
|
||||
});
|
||||
|
||||
|
||||
QUnit.test("delegateEvents ignore undefined methods", function(assert) {
|
||||
QUnit.test('delegateEvents ignore undefined methods', function(assert) {
|
||||
assert.expect(0);
|
||||
var view = new Backbone.View({el: '<p></p>'});
|
||||
view.delegateEvents({'click': 'undefinedMethod'});
|
||||
view.$el.trigger('click');
|
||||
});
|
||||
|
||||
QUnit.test("undelegateEvents", function(assert) {
|
||||
QUnit.test('undelegateEvents', function(assert) {
|
||||
assert.expect(7);
|
||||
var counter1 = 0, counter2 = 0;
|
||||
|
||||
@@ -160,7 +160,7 @@
|
||||
assert.equal(view.undelegateEvents(), view, '#undelegateEvents returns the view instance');
|
||||
});
|
||||
|
||||
QUnit.test("undelegate", function(assert) {
|
||||
QUnit.test('undelegate', function(assert) {
|
||||
assert.expect(1);
|
||||
view = new Backbone.View({el: '#testElement'});
|
||||
view.delegate('click', function() { assert.ok(false); });
|
||||
@@ -174,7 +174,7 @@
|
||||
assert.equal(view.undelegate(), view, '#undelegate returns the view instance');
|
||||
});
|
||||
|
||||
QUnit.test("undelegate with passed handler", function(assert) {
|
||||
QUnit.test('undelegate with passed handler', function(assert) {
|
||||
assert.expect(1);
|
||||
view = new Backbone.View({el: '#testElement'});
|
||||
var listener = function() { assert.ok(false); };
|
||||
@@ -184,7 +184,7 @@
|
||||
view.$el.trigger('click');
|
||||
});
|
||||
|
||||
QUnit.test("undelegate with selector", function(assert) {
|
||||
QUnit.test('undelegate with selector', function(assert) {
|
||||
assert.expect(2);
|
||||
view = new Backbone.View({el: '#testElement'});
|
||||
view.delegate('click', function() { assert.ok(true); });
|
||||
@@ -194,7 +194,7 @@
|
||||
view.$el.trigger('click');
|
||||
});
|
||||
|
||||
QUnit.test("undelegate with handler and selector", function(assert) {
|
||||
QUnit.test('undelegate with handler and selector', function(assert) {
|
||||
assert.expect(2);
|
||||
view = new Backbone.View({el: '#testElement'});
|
||||
view.delegate('click', function() { assert.ok(true); });
|
||||
@@ -205,7 +205,7 @@
|
||||
view.$el.trigger('click');
|
||||
});
|
||||
|
||||
QUnit.test("tagName can be provided as a string", function(assert) {
|
||||
QUnit.test('tagName can be provided as a string', function(assert) {
|
||||
assert.expect(1);
|
||||
var View = Backbone.View.extend({
|
||||
tagName: 'span'
|
||||
@@ -214,7 +214,7 @@
|
||||
assert.equal(new View().el.tagName, 'SPAN');
|
||||
});
|
||||
|
||||
QUnit.test("tagName can be provided as a function", function(assert) {
|
||||
QUnit.test('tagName can be provided as a function', function(assert) {
|
||||
assert.expect(1);
|
||||
var View = Backbone.View.extend({
|
||||
tagName: function() {
|
||||
@@ -225,7 +225,7 @@
|
||||
assert.ok(new View().$el.is('p'));
|
||||
});
|
||||
|
||||
QUnit.test("_ensureElement with DOM node el", function(assert) {
|
||||
QUnit.test('_ensureElement with DOM node el', function(assert) {
|
||||
assert.expect(1);
|
||||
var View = Backbone.View.extend({
|
||||
el: document.body
|
||||
@@ -234,25 +234,25 @@
|
||||
assert.equal(new View().el, document.body);
|
||||
});
|
||||
|
||||
QUnit.test("_ensureElement with string el", function(assert) {
|
||||
QUnit.test('_ensureElement with string el', function(assert) {
|
||||
assert.expect(3);
|
||||
var View = Backbone.View.extend({
|
||||
el: "body"
|
||||
el: 'body'
|
||||
});
|
||||
assert.strictEqual(new View().el, document.body);
|
||||
|
||||
View = Backbone.View.extend({
|
||||
el: "#testElement > h1"
|
||||
el: '#testElement > h1'
|
||||
});
|
||||
assert.strictEqual(new View().el, $("#testElement > h1").get(0));
|
||||
assert.strictEqual(new View().el, $('#testElement > h1').get(0));
|
||||
|
||||
View = Backbone.View.extend({
|
||||
el: "#nonexistent"
|
||||
el: '#nonexistent'
|
||||
});
|
||||
assert.ok(!new View().el);
|
||||
});
|
||||
|
||||
QUnit.test("with className and id functions", function(assert) {
|
||||
QUnit.test('with className and id functions', function(assert) {
|
||||
assert.expect(2);
|
||||
var View = Backbone.View.extend({
|
||||
className: function() {
|
||||
@@ -267,11 +267,11 @@
|
||||
assert.strictEqual(new View().el.id, 'id');
|
||||
});
|
||||
|
||||
QUnit.test("with attributes", function(assert) {
|
||||
QUnit.test('with attributes', function(assert) {
|
||||
assert.expect(2);
|
||||
var View = Backbone.View.extend({
|
||||
attributes: {
|
||||
id: 'id',
|
||||
'id': 'id',
|
||||
'class': 'class'
|
||||
}
|
||||
});
|
||||
@@ -280,7 +280,7 @@
|
||||
assert.strictEqual(new View().el.id, 'id');
|
||||
});
|
||||
|
||||
QUnit.test("with attributes as a function", function(assert) {
|
||||
QUnit.test('with attributes as a function', function(assert) {
|
||||
assert.expect(1);
|
||||
var View = Backbone.View.extend({
|
||||
attributes: function() {
|
||||
@@ -291,7 +291,7 @@
|
||||
assert.strictEqual(new View().el.className, 'dynamic');
|
||||
});
|
||||
|
||||
QUnit.test("should default to className/id properties", function(assert) {
|
||||
QUnit.test('should default to className/id properties', function(assert) {
|
||||
assert.expect(4);
|
||||
var View = Backbone.View.extend({
|
||||
className: 'backboneClass',
|
||||
@@ -309,7 +309,7 @@
|
||||
assert.strictEqual(view.$el.attr('id'), 'backboneId');
|
||||
});
|
||||
|
||||
QUnit.test("multiple views per element", function(assert) {
|
||||
QUnit.test('multiple views per element', function(assert) {
|
||||
assert.expect(3);
|
||||
var count = 0;
|
||||
var $el = $('<p></p>');
|
||||
@@ -324,24 +324,24 @@
|
||||
});
|
||||
|
||||
var view1 = new View;
|
||||
$el.trigger("click");
|
||||
$el.trigger('click');
|
||||
assert.equal(1, count);
|
||||
|
||||
var view2 = new View;
|
||||
$el.trigger("click");
|
||||
$el.trigger('click');
|
||||
assert.equal(3, count);
|
||||
|
||||
view1.delegateEvents();
|
||||
$el.trigger("click");
|
||||
$el.trigger('click');
|
||||
assert.equal(5, count);
|
||||
});
|
||||
|
||||
QUnit.test("custom events", function(assert) {
|
||||
QUnit.test('custom events', function(assert) {
|
||||
assert.expect(2);
|
||||
var View = Backbone.View.extend({
|
||||
el: $('body'),
|
||||
events: {
|
||||
"fake$event": function() { assert.ok(true); }
|
||||
fake$event: function() { assert.ok(true); }
|
||||
}
|
||||
});
|
||||
|
||||
@@ -352,7 +352,7 @@
|
||||
$('body').trigger('fake$event');
|
||||
});
|
||||
|
||||
QUnit.test("#1048 - setElement uses provided object.", function(assert) {
|
||||
QUnit.test('#1048 - setElement uses provided object.', function(assert) {
|
||||
assert.expect(2);
|
||||
var $el = $('body');
|
||||
|
||||
@@ -363,7 +363,7 @@
|
||||
assert.ok(view.$el === $el);
|
||||
});
|
||||
|
||||
QUnit.test("#986 - Undelegate before changing element.", function(assert) {
|
||||
QUnit.test('#986 - Undelegate before changing element.', function(assert) {
|
||||
assert.expect(1);
|
||||
var button1 = $('<button></button>');
|
||||
var button2 = $('<button></button>');
|
||||
@@ -383,7 +383,7 @@
|
||||
button2.trigger('click');
|
||||
});
|
||||
|
||||
QUnit.test("#1172 - Clone attributes object", function(assert) {
|
||||
QUnit.test('#1172 - Clone attributes object', function(assert) {
|
||||
assert.expect(2);
|
||||
var View = Backbone.View.extend({
|
||||
attributes: {foo: 'bar'}
|
||||
@@ -396,7 +396,7 @@
|
||||
assert.ok(!view2.el.id);
|
||||
});
|
||||
|
||||
QUnit.test("views stopListening", function(assert) {
|
||||
QUnit.test('views stopListening', function(assert) {
|
||||
assert.expect(0);
|
||||
var View = Backbone.View.extend({
|
||||
initialize: function() {
|
||||
@@ -415,11 +415,11 @@
|
||||
view.collection.trigger('x');
|
||||
});
|
||||
|
||||
QUnit.test("Provide function for el.", function(assert) {
|
||||
QUnit.test('Provide function for el.', function(assert) {
|
||||
assert.expect(2);
|
||||
var View = Backbone.View.extend({
|
||||
el: function() {
|
||||
return "<p><a></a></p>";
|
||||
return '<p><a></a></p>';
|
||||
}
|
||||
});
|
||||
|
||||
@@ -428,7 +428,7 @@
|
||||
assert.ok(view.$el.has('a'));
|
||||
});
|
||||
|
||||
QUnit.test("events passed in options", function(assert) {
|
||||
QUnit.test('events passed in options', function(assert) {
|
||||
assert.expect(1);
|
||||
var counter = 0;
|
||||
|
||||
@@ -449,7 +449,7 @@
|
||||
assert.equal(counter, 2);
|
||||
});
|
||||
|
||||
QUnit.test("remove", function(assert) {
|
||||
QUnit.test('remove', function(assert) {
|
||||
assert.expect(2);
|
||||
var view = new Backbone.View;
|
||||
document.body.appendChild(view.el);
|
||||
@@ -465,7 +465,7 @@
|
||||
assert.notEqual(view.el.parentNode, document.body);
|
||||
});
|
||||
|
||||
QUnit.test("setElement", function(assert) {
|
||||
QUnit.test('setElement', function(assert) {
|
||||
assert.expect(3);
|
||||
var view = new Backbone.View({
|
||||
events: {
|
||||
|
||||
8
vendor/underscore/test/collections.js
vendored
8
vendor/underscore/test/collections.js
vendored
@@ -67,11 +67,7 @@
|
||||
|
||||
var tricks = [
|
||||
{length: '5'},
|
||||
{
|
||||
length: {
|
||||
valueOf: _.constant(5)
|
||||
}
|
||||
},
|
||||
{length: {valueOf: _.constant(5)}},
|
||||
{length: Math.pow(2, 53) + 1},
|
||||
{length: Math.pow(2, 53)},
|
||||
{length: null},
|
||||
@@ -821,7 +817,7 @@
|
||||
var actual;
|
||||
try {
|
||||
actual = _.toArray(document.childNodes);
|
||||
} catch(e) { /* ignored */ }
|
||||
} catch (e) { /* ignored */ }
|
||||
assert.deepEqual(actual, _.map(document.childNodes, _.identity), 'works on NodeList');
|
||||
}
|
||||
});
|
||||
|
||||
3
vendor/underscore/test/functions.js
vendored
3
vendor/underscore/test/functions.js
vendored
@@ -90,7 +90,8 @@
|
||||
});
|
||||
|
||||
QUnit.test('bindAll', function(assert) {
|
||||
var curly = {name: 'curly'}, moe = {
|
||||
var curly = {name: 'curly'};
|
||||
var moe = {
|
||||
name: 'moe',
|
||||
getName: function() { return 'name: ' + this.name; },
|
||||
sayHi: function() { return 'hi: ' + this.name; }
|
||||
|
||||
14
vendor/underscore/test/objects.js
vendored
14
vendor/underscore/test/objects.js
vendored
@@ -128,7 +128,7 @@
|
||||
try {
|
||||
result = {};
|
||||
_.extend(result, null, void 0, {a: 1});
|
||||
} catch(e) { /* ignored */ }
|
||||
} catch (e) { /* ignored */ }
|
||||
|
||||
assert.equal(result.a, 1, 'should not error on `null` or `undefined` sources');
|
||||
|
||||
@@ -262,7 +262,7 @@
|
||||
try {
|
||||
options = {};
|
||||
_.defaults(options, null, void 0, {a: 1});
|
||||
} catch(e) { /* ignored */ }
|
||||
} catch (e) { /* ignored */ }
|
||||
|
||||
assert.equal(options.a, 1, 'should not error on `null` or `undefined` sources');
|
||||
|
||||
@@ -842,14 +842,14 @@
|
||||
|
||||
assert.ok(_.find(stooges, _.matcher({hair: false})) === curly, 'returns a predicate that can be used by finding functions.');
|
||||
assert.ok(_.find(stooges, _.matcher(moe)) === moe, 'can be used to locate an object exists in a collection.');
|
||||
assert.deepEqual(_.where([null, void 0], {a: 1}), [], 'Do not throw on null values.');
|
||||
assert.deepEqual(_.filter([null, void 0], _.matcher({a: 1})), [], 'Do not throw on null values.');
|
||||
|
||||
assert.deepEqual(_.where([null, void 0], null), [null, void 0], 'null matches null');
|
||||
assert.deepEqual(_.where([null, void 0], {}), [null, void 0], 'null matches {}');
|
||||
assert.deepEqual(_.where([{b: 1}], {a: void 0}), [], 'handles undefined values (1683)');
|
||||
assert.deepEqual(_.filter([null, void 0], _.matcher(null)), [null, void 0], 'null matches null');
|
||||
assert.deepEqual(_.filter([null, void 0], _.matcher({})), [null, void 0], 'null matches {}');
|
||||
assert.deepEqual(_.filter([{b: 1}], _.matcher({a: void 0})), [], 'handles undefined values (1683)');
|
||||
|
||||
_.each([true, 5, NaN, null, void 0], function(item) {
|
||||
assert.deepEqual(_.where([{a: 1}], item), [{a: 1}], 'treats primitives as empty');
|
||||
assert.equal(_.matcher(item)({a: 1}), true, 'treats primitives as empty');
|
||||
});
|
||||
|
||||
function Prototest() {}
|
||||
|
||||
6
vendor/underscore/underscore.js
vendored
6
vendor/underscore/underscore.js
vendored
@@ -22,16 +22,14 @@
|
||||
var ArrayProto = Array.prototype, ObjProto = Object.prototype;
|
||||
|
||||
// Create quick reference variables for speed access to core prototypes.
|
||||
var
|
||||
push = ArrayProto.push,
|
||||
var push = ArrayProto.push,
|
||||
slice = ArrayProto.slice,
|
||||
toString = ObjProto.toString,
|
||||
hasOwnProperty = ObjProto.hasOwnProperty;
|
||||
|
||||
// All **ECMAScript 5** native function implementations that we hope to use
|
||||
// are declared here.
|
||||
var
|
||||
nativeIsArray = Array.isArray,
|
||||
var nativeIsArray = Array.isArray,
|
||||
nativeKeys = Object.keys,
|
||||
nativeCreate = Object.create;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user