Route gets arrays

This commit is contained in:
Vit Brunner
2014-12-19 18:40:23 +01:00
parent 6065895437
commit 6d039a8230
2 changed files with 45 additions and 14 deletions
+36 -13
View File
@@ -1,24 +1,25 @@
route = {}
module "route", {
setup: () ->
angular.module("sideBySide").service("$location", () ->
@path = () ->
'/asdf:zxcv/qwerty:asdf'
@url = () ->
'/asdf:zxcv/qwerty:asdf#test'
@absUrl = () ->
'http://example.com/asdf:zxcv/qwerty:asdf#test'
@
)
module "route", {}
route = angular.injector(['ng', 'sideBySide']).get('route')
}
simpleSetup = () ->
angular.module("sideBySide").service("$location", () ->
@path = () ->
'/asdf:zxcv/qwerty:asdf'
@url = () ->
'/asdf:zxcv/qwerty:asdf#test'
@absUrl = () ->
'http://example.com/asdf:zxcv/qwerty:asdf#test'
@
)
route = angular.injector(['ng', 'sideBySide']).get('route')
test "has app url", () ->
simpleSetup()
equal route.appUrl, 'http://example.com'
test "gets parameters", () ->
simpleSetup()
deepEqual route.params, {
'asdf': 'zxcv'
'qwerty': 'asdf'
@@ -26,6 +27,7 @@ test "gets parameters", () ->
}
test "updates parameters", () ->
simpleSetup()
route.update('asdf', 'hjkl')
deepEqual route.params, {
'asdf': 'hjkl'
@@ -34,6 +36,7 @@ test "updates parameters", () ->
}
test "adds parameter", () ->
simpleSetup()
route.update('new', 'one')
deepEqual route.params, {
'asdf': 'zxcv'
@@ -41,3 +44,23 @@ test "adds parameter", () ->
'base': ''
'new': 'one'
}
test "gets arrays", () ->
angular.module("sideBySide").service("$location", () ->
urlPath = '/display:Language:Czech,English'
@path = () ->
urlPath
@url = () ->
urlPath
@absUrl = () ->
'http://example.com/' + urlPath
@
)
route = angular.injector(['ng', 'sideBySide']).get('route')
deepEqual route.params, {
'base': ''
'display': {
'Language': [ 'Czech', 'English' ]
}
}