[Pkg-javascript-commits] [backbone] 124/173: Adding a unit test for once with object notation

Jonas Smedegaard dr at jones.dk
Wed Aug 31 07:44:11 UTC 2016


This is an automated email from the git hooks/post-receive script.

js pushed a commit to branch master
in repository backbone.

commit d2099dd283dd20e7783f585a6832bb0a8a45e384
Author: Royce Tucker <royce.tucker at perceptivesoftware.com>
Date:   Sat Jan 30 14:37:37 2016 -0600

    Adding a unit test for once with object notation
---
 test/events.js | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/test/events.js b/test/events.js
index b9b5053..bebcb0e 100644
--- a/test/events.js
+++ b/test/events.js
@@ -587,6 +587,19 @@
     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 = {};

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/backbone.git



More information about the Pkg-javascript-commits mailing list