Merge branch 'route-query-string' of github.com:yolk/mithril.js into yolk-route-query-string

Conflicts:
	tests/mithril-tests.js
This commit is contained in:
Leo Horie 2014-05-24 20:11:34 -04:00
commit 80379bcd1b
2 changed files with 83 additions and 9 deletions

View file

@ -594,6 +594,53 @@ function testMithril(mock) {
mock.performance.$elapse(50) //teardown
return mock.location.search == "?/test11/" && root.childNodes[0].nodeValue === "bar"
})
test(function() {
mock.performance.$elapse(50) //setup
mock.location.search = "?"
var root = mock.document.createElement("div")
m.route.mode = "search"
m.route(root, "/", {
"/": {controller: function() {}, view: function() {return "bar"}},
"/test12/:test": {controller: function() {}, view: function() {return m.route.param("test")}}
})
mock.performance.$elapse(50)
m.route("/test12/foo?test=bar")
mock.performance.$elapse(50) //teardown
return mock.location.search == "?/test12/foo?test=bar" && root.childNodes[0].nodeValue === "foo"
})
test(function() {
mock.performance.$elapse(50) //setup
mock.location.search = "?"
var root = mock.document.createElement("div")
m.route.mode = "search"
m.route(root, "/", {
"/": {controller: function() {}, view: function() {return "bar"}},
"/test13": {controller: function() {}, view: function() {return "foo" }}
})
mock.performance.$elapse(50)
m.route("/test13?test&test2=")
mock.performance.$elapse(50) //teardown
return mock.location.search == "?/test13?test&test2=" && m.route.param("test") === true && m.route.param("test2") === ""
})
test(function() {
mock.performance.$elapse(50) //setup
mock.location.search = "?"
var root = mock.document.createElement("div")
m.route.mode = "search"
m.route(root, "/", {
"/": {controller: function() {}, view: function() { return "bar" }},
"/test14": {controller: function() {}, view: function() { return "foo" }}
})
mock.performance.$elapse(50)
var path = "/test14?obj[a]=foo&obj[b][c]=1&obj[b][d]=2&str=bar"
m.route(path)
var paramValue = m.route.param("obj")
mock.performance.$elapse(50) //teardown
return true; mock.location.search == path && paramValue.a == "foo" && paramValue.b.c == "1" && paramValue.b.d == "2" && m.route.param("str") == "bar"
})
//end m.route
//m.prop