From a2b45ff131bad507db14e8deb8fa79d9819309b0 Mon Sep 17 00:00:00 2001 From: Leo Horie Date: Sun, 4 Dec 2016 23:36:38 -0500 Subject: [PATCH] add integration test --- api/tests/test-router.js | 23 +++++++++++++++++++++++ tests/test-api.js | 2 +- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/api/tests/test-router.js b/api/tests/test-router.js index 5b7ddf3e..302c1e27 100644 --- a/api/tests/test-router.js +++ b/api/tests/test-router.js @@ -609,6 +609,29 @@ o.spec("route", function() { }, 30) }) + o("route changes activate onbeforeremove", function(done, timeout) { + var spy = o.spy() + + $window.location.href = prefix + "/a" + route(root, "/a", { + "/a": { + onbeforeremove: spy, + view: function() {} + }, + "/b": { + view: function() {} + } + }) + + route.set("/b") + + setTimeout(function() { + o(spy.callCount).equals(1) + + done() + }, 30) + }) + o("throttles", function(done, timeout) { timeout(200) diff --git a/tests/test-api.js b/tests/test-api.js index 3b977ab1..0a5824f9 100644 --- a/tests/test-api.js +++ b/tests/test-api.js @@ -8,7 +8,7 @@ o.spec("api", function() { var FRAME_BUDGET = Math.floor(1000 / 60) o.beforeEach(function() { var mock = browserMock() - if (typeof global !== "undefined") global.window = mock, global.document = mock.document + if (typeof global !== "undefined") global.window = mock m = require("../mithril") })