Built motion from commit 76eb00b9e.|1.0.24
[motion.git] / public / bower_components / lodash / vendor / backbone / test / events.js
index b9b5053..ec1e547 100644 (file)
@@ -1,4 +1,4 @@
-(function() {
+(function(QUnit) {
 
   QUnit.module('Backbone.Events');
 
     assert.equal(obj.counterB, 1, 'counterB should have only been incremented once.');
   });
 
+  QUnit.test('bind a callback with a default context when none supplied', function(assert) {
+    assert.expect(1);
+    var obj = _.extend({
+      assertTrue: function() {
+        assert.equal(this, obj, '`this` was bound to the callback');
+      }
+    }, Backbone.Events);
+
+    obj.once('event', obj.assertTrue);
+    obj.trigger('event');
+  });
+
   QUnit.test('bind a callback with a supplied context', function(assert) {
     assert.expect(1);
     var TestClass = function() {
     assert.equal(obj.counter, 3);
   });
 
+  QUnit.test('bind a callback with a supplied context using once with object notation', function(assert) {
+    assert.expect(1);
+    var obj = {counter: 0};
+    var context = {};
+    _.extend(obj, Backbone.Events);
+
+    obj.once({
+      a: function() {
+        assert.strictEqual(this, context, 'defaults `context` to `callback` param');
+      }
+    }, context).trigger('a');
+  });
+
   QUnit.test('once with off only by context', function(assert) {
     assert.expect(0);
     var context = {};
     two.trigger('y', 2);
   });
 
-})();
+})(QUnit);