semi-working bundle
This commit is contained in:
parent
41cfda2719
commit
5265697cb2
20 changed files with 1391 additions and 123 deletions
46
router/tests/test-getPath.js
Normal file
46
router/tests/test-getPath.js
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
"use strict"
|
||||
|
||||
var o = require("../../ospec/ospec")
|
||||
var pushStateMock = require("../../test-utils/pushStateMock")
|
||||
var Router = require("../../router/router")
|
||||
|
||||
o.spec("Router.getPath", function() {
|
||||
void ["#", "?", "", "#!", "?!"].forEach(function(prefix) {
|
||||
o.spec("using prefix `" + prefix + "`", function() {
|
||||
var $window, router, onRouteChange, onFail
|
||||
|
||||
o.beforeEach(function() {
|
||||
$window = pushStateMock()
|
||||
router = new Router($window)
|
||||
router.setPrefix(prefix)
|
||||
onRouteChange = o.spy()
|
||||
onFail = o.spy()
|
||||
})
|
||||
|
||||
o("gets route", function() {
|
||||
$window.location.href = prefix + "/test"
|
||||
router.defineRoutes({"/test": {data: 1}}, onRouteChange, onFail)
|
||||
|
||||
o(router.getPath()).equals("/test")
|
||||
})
|
||||
o("gets route w/ params", function() {
|
||||
$window.location.href = prefix + "/other/x/y/z?c=d#e=f"
|
||||
router.defineRoutes({"/test": {data: 1}, "/other/:a/:b...": {data: 2}}, onRouteChange, onFail)
|
||||
|
||||
o(router.getPath()).equals("/other/x/y/z?c=d#e=f")
|
||||
})
|
||||
o("gets route w/ escaped unicode", function() {
|
||||
$window.location.href = prefix + "/%C3%B6?%C3%B6=%C3%B6#%C3%B6=%C3%B6"
|
||||
router.defineRoutes({"/test": {data: 1}, "/ö/:a/:b...": {data: 2}}, onRouteChange, onFail)
|
||||
|
||||
o(router.getPath()).equals("/ö?ö=ö#ö=ö")
|
||||
})
|
||||
o("gets route w/ unicode", function() {
|
||||
$window.location.href = prefix + "/ö?ö=ö#ö=ö"
|
||||
router.defineRoutes({"/test": {data: 1}, "/ö/:a/:b...": {data: 2}}, onRouteChange, onFail)
|
||||
|
||||
o(router.getPath()).equals("/ö?ö=ö#ö=ö")
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue