fix tests

This commit is contained in:
Leo Horie 2016-12-06 00:09:09 -05:00
parent adabc37fd7
commit 3134202d24
8 changed files with 145 additions and 119 deletions

View file

@ -1,6 +1,5 @@
"use strict"
var Promise = require("../promise/promise")
var buildQueryString = require("../querystring/build")
var parseQueryString = require("../querystring/parse")
@ -18,15 +17,13 @@ module.exports = function($window) {
}
var asyncId
function debounceAsync(f) {
function debounceAsync(callback) {
return function() {
return new Promise(function(resolve, reject) {
if (asyncId != null) return reject()
asyncId = callAsync(function() {
asyncId = null
resolve(f())
})
});
if (asyncId != null) return
asyncId = callAsync(function() {
asyncId = null
callback()
})
}
}
@ -75,12 +72,9 @@ module.exports = function($window) {
if (supportsPushState) {
if (options && options.replace) $window.history.replaceState(null, null, prefix + path)
else $window.history.pushState(null, null, prefix + path)
return $window.onpopstate()
}
else {
$window.location.href = prefix + path
return Promise.resolve(prefix + path)
$window.onpopstate()
}
else $window.location.href = prefix + path
}
function defineRoutes(routes, resolve, reject) {
@ -121,7 +115,7 @@ module.exports = function($window) {
e.redraw = false
var href = this.getAttribute("href")
if (href.indexOf(prefix) === 0) href = href.slice(prefix.length)
return setPath(href, undefined, undefined)
setPath(href, undefined, undefined)
}
}

View file

@ -11,6 +11,7 @@
<script src="../../test-utils/pushStateMock.js"></script>
<script src="../../test-utils/domMock.js"></script>
<script src="../../promise/promise.js"></script>
<script src="../../render/vnode.js"></script>
<script src="../../render/render.js"></script>
<script src="../../querystring/build.js"></script>