[Pkg-javascript-commits] [backbone] 163/281: adding a test to ensure that routes aren't triggered multiple times. #849

Jonas Smedegaard js at moszumanska.debian.org
Sat May 3 17:02:08 UTC 2014


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

js pushed a commit to tag 0.9.0
in repository backbone.

commit 2312b9072cb1880f7acc08c115cceb2378400b9f
Author: Jeremy Ashkenas <jashkenas at gmail.com>
Date:   Wed Jan 11 12:11:10 2012 -0500

    adding a test to ensure that routes aren't triggered multiple times. #849
---
 test/router.js | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/test/router.js b/test/router.js
index 88882f9..4037322 100644
--- a/test/router.js
+++ b/test/router.js
@@ -4,8 +4,11 @@ $(document).ready(function() {
 
   var Router = Backbone.Router.extend({
 
+    count: 0,
+
     routes: {
       "noCallback":                 "noCallback",
+      "counter":                    "counter",
       "search/:query":              "search",
       "search/:query/p:page":       "search",
       "splat/*args/end":            "splat",
@@ -18,6 +21,10 @@ $(document).ready(function() {
       this.testing = options.testing;
     },
 
+    counter: function() {
+      this.count++;
+    },
+
     search : function(query, page) {
       this.query = query;
       this.page = page;
@@ -86,6 +93,18 @@ $(document).ready(function() {
     equals(router.page, '20');
   });
 
+  test("Router: doesn't fire routes to the same place twice", function() {
+    equals(router.count, 0);
+    router.navigate('counter', {trigger: true});
+    equals(router.count, 1);
+    router.navigate('counter', {trigger: true});
+    router.navigate('counter', {trigger: true});
+    equals(router.count, 1);
+    router.navigate('search/counter', {trigger: true});
+    router.navigate('counter', {trigger: true});
+    equals(router.count, 2);
+  });
+
   asyncTest("Router: routes via navigate with {replace: true}", function() {
     var historyLength = window.history.length;
     router.navigate('search/manhattan/start_here');

-- 
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