diff --git a/api/tests/test-mount.js b/api/tests/test-mount.js index 80ade907..6bc69ce9 100644 --- a/api/tests/test-mount.js +++ b/api/tests/test-mount.js @@ -11,7 +11,6 @@ var apiRedraw = require("../../api/redraw") var apiMounter = require("../../api/mount") o.spec("mount", function() { - var FRAME_BUDGET = Math.floor(1000 / 60) var $window, root, redrawService, mount, render, throttleMock o.beforeEach(function() { diff --git a/api/tests/test-redraw.js b/api/tests/test-redraw.js index 68b1a911..65831bb0 100644 --- a/api/tests/test-redraw.js +++ b/api/tests/test-redraw.js @@ -166,6 +166,6 @@ o.spec("redrawService", function() { o(spy1.callCount).equals(2) o(spy2.callCount).equals(2) - o(spy3.callCount).equals(2) + o(spy3.callCount).equals(2) }) }) diff --git a/api/tests/test-router.js b/api/tests/test-router.js index bc3e7023..ad009667 100644 --- a/api/tests/test-router.js +++ b/api/tests/test-router.js @@ -15,7 +15,6 @@ o.spec("route", function() { void [{protocol: "http:", hostname: "localhost"}, {protocol: "file:", hostname: "/"}].forEach(function(env) { void ["#", "?", "", "#!", "?!", "/foo"].forEach(function(prefix) { o.spec("using prefix `" + prefix + "` starting on " + env.protocol + "//" + env.hostname, function() { - var FRAME_BUDGET = Math.floor(1000 / 60) var $window, root, redrawService, route, throttleMock o.beforeEach(function() { @@ -552,12 +551,12 @@ o.spec("route", function() { route(root, "/a", { "/a" : { render: function() { - return m("div", m('p')) + return m("div", m("p")) }, }, "/b" : { render: function() { - return m("div", m('a')) + return m("div", m("a")) }, }, }) @@ -840,7 +839,7 @@ o.spec("route", function() { callAsync(function() { throttleMock.fire() - route.set('/b') + route.set("/b") callAsync(function() { callAsync(function() { callAsync(function() { @@ -1110,7 +1109,7 @@ o.spec("route", function() { o(root.firstChild.nodeName).equals("B") - route.set('/a') + route.set("/a") callAsync(function() { throttleMock.fire() diff --git a/test-utils/tests/test-throttleMock.js b/test-utils/tests/test-throttleMock.js index 8126af05..69920623 100644 --- a/test-utils/tests/test-throttleMock.js +++ b/test-utils/tests/test-throttleMock.js @@ -1,89 +1,91 @@ +"use strict" + var o = require("../../ospec/ospec") var throttleMocker = require("../../test-utils/throttleMock") o.spec("throttleMock", function() { - o("works with one callback", function() { - var throttleMock = throttleMocker() - var spy = o.spy() + o("works with one callback", function() { + var throttleMock = throttleMocker() + var spy = o.spy() - o(throttleMock.queueLength()).equals(0) + o(throttleMock.queueLength()).equals(0) - var throttled = throttleMock.throttle(spy) + var throttled = throttleMock.throttle(spy) - o(throttleMock.queueLength()).equals(0) - o(spy.callCount).equals(0) + o(throttleMock.queueLength()).equals(0) + o(spy.callCount).equals(0) - throttled() + throttled() - o(throttleMock.queueLength()).equals(1) - o(spy.callCount).equals(0) + o(throttleMock.queueLength()).equals(1) + o(spy.callCount).equals(0) - throttled() + throttled() - o(throttleMock.queueLength()).equals(1) - o(spy.callCount).equals(0) + o(throttleMock.queueLength()).equals(1) + o(spy.callCount).equals(0) - throttleMock.fire() + throttleMock.fire() - o(throttleMock.queueLength()).equals(0) - o(spy.callCount).equals(1) + o(throttleMock.queueLength()).equals(0) + o(spy.callCount).equals(1) - throttleMock.fire() + throttleMock.fire() - o(spy.callCount).equals(1) - }) - o("works with two callbacks", function() { - var throttleMock = throttleMocker() - var spy1 = o.spy() - var spy2 = o.spy() + o(spy.callCount).equals(1) + }) + o("works with two callbacks", function() { + var throttleMock = throttleMocker() + var spy1 = o.spy() + var spy2 = o.spy() - o(throttleMock.queueLength()).equals(0) + o(throttleMock.queueLength()).equals(0) - var throttled1 = throttleMock.throttle(spy1) + var throttled1 = throttleMock.throttle(spy1) - o(throttleMock.queueLength()).equals(0) - o(spy1.callCount).equals(0) - o(spy2.callCount).equals(0) + o(throttleMock.queueLength()).equals(0) + o(spy1.callCount).equals(0) + o(spy2.callCount).equals(0) - throttled1() + throttled1() - o(throttleMock.queueLength()).equals(1) - o(spy1.callCount).equals(0) - o(spy2.callCount).equals(0) + o(throttleMock.queueLength()).equals(1) + o(spy1.callCount).equals(0) + o(spy2.callCount).equals(0) - throttled1() + throttled1() - o(throttleMock.queueLength()).equals(1) - o(spy1.callCount).equals(0) - o(spy2.callCount).equals(0) + o(throttleMock.queueLength()).equals(1) + o(spy1.callCount).equals(0) + o(spy2.callCount).equals(0) - var throttled2 = throttleMock.throttle(spy2) + var throttled2 = throttleMock.throttle(spy2) - o(throttleMock.queueLength()).equals(1) - o(spy1.callCount).equals(0) - o(spy2.callCount).equals(0) + o(throttleMock.queueLength()).equals(1) + o(spy1.callCount).equals(0) + o(spy2.callCount).equals(0) - throttled2() + throttled2() - o(throttleMock.queueLength()).equals(2) - o(spy1.callCount).equals(0) - o(spy2.callCount).equals(0) + o(throttleMock.queueLength()).equals(2) + o(spy1.callCount).equals(0) + o(spy2.callCount).equals(0) - throttled2() + throttled2() - o(throttleMock.queueLength()).equals(2) - o(spy1.callCount).equals(0) - o(spy2.callCount).equals(0) + o(throttleMock.queueLength()).equals(2) + o(spy1.callCount).equals(0) + o(spy2.callCount).equals(0) - throttleMock.fire() + throttleMock.fire() - o(throttleMock.queueLength()).equals(0) - o(spy1.callCount).equals(1) - o(spy2.callCount).equals(1) + o(throttleMock.queueLength()).equals(0) + o(spy1.callCount).equals(1) + o(spy2.callCount).equals(1) - throttleMock.fire() + throttleMock.fire() - o(spy1.callCount).equals(1) - o(spy2.callCount).equals(1) - }) + o(spy1.callCount).equals(1) + o(spy2.callCount).equals(1) + }) }) diff --git a/test-utils/throttleMock.js b/test-utils/throttleMock.js index 06e74f99..6cdb5710 100644 --- a/test-utils/throttleMock.js +++ b/test-utils/throttleMock.js @@ -1,25 +1,27 @@ +"use strict" + module.exports = function() { - var queue = [] - return { - throttle: function(fn) { - var pending = false - return function() { - if (!pending) { - queue.push(function(){ - pending = false - fn() - }) - pending = true - } - } - }, - fire: function() { - var tasks = queue - queue = [] - tasks.forEach(function(fn) {fn()}) - }, - queueLength: function(){ - return queue.length - } - } + var queue = [] + return { + throttle: function(fn) { + var pending = false + return function() { + if (!pending) { + queue.push(function(){ + pending = false + fn() + }) + pending = true + } + } + }, + fire: function() { + var tasks = queue + queue = [] + tasks.forEach(function(fn) {fn()}) + }, + queueLength: function(){ + return queue.length + } + } }