diff options
author | Bernhard Posselt <dev@bernhard-posselt.com> | 2014-05-15 03:00:53 +0200 |
---|---|---|
committer | Bernhard Posselt <dev@bernhard-posselt.com> | 2014-05-15 03:00:53 +0200 |
commit | 3ce894af1e72c9488b8cb3340fd61656122f7d50 (patch) | |
tree | a603121e8b1e860201370399f8095121cd9c6bf7 /js/vendor/angular-ui/modules/directives/route/test/routeSpec.js | |
parent | 10d76fff64363ea59d916b550854cf3540dadfbc (diff) |
use markdown, refactor js
Diffstat (limited to 'js/vendor/angular-ui/modules/directives/route/test/routeSpec.js')
-rw-r--r-- | js/vendor/angular-ui/modules/directives/route/test/routeSpec.js | 98 |
1 files changed, 0 insertions, 98 deletions
diff --git a/js/vendor/angular-ui/modules/directives/route/test/routeSpec.js b/js/vendor/angular-ui/modules/directives/route/test/routeSpec.js deleted file mode 100644 index d16bafbfe..000000000 --- a/js/vendor/angular-ui/modules/directives/route/test/routeSpec.js +++ /dev/null @@ -1,98 +0,0 @@ -/*global describe, beforeEach, module, inject, it, spyOn, expect, $ */ -describe('uiRoute', function () { - 'use strict'; - - var scope, $compile, $location; - beforeEach(module('ui.directives')); - beforeEach(inject(function (_$rootScope_, _$compile_, _$window_, _$location_) { - scope = _$rootScope_.$new(); - $compile = _$compile_; - $location = _$location_; - })); - - function setPath(path) { - $location.path(path); - scope.$broadcast('$routeChangeSuccess'); - scope.$apply(); - } - - describe('model is null', function() { - runTests(); - }); - describe('model is set', function() { - runTests('pizza'); - }); - - function runTests(routeModel) { - function compileRoute(template) { - var elm = $(template); - if (routeModel) elm.attr('ng-model', routeModel); - return $compile(elm[0])(scope); - } - var modelProp = routeModel || '$uiRoute'; - describe('with uiRoute defined', function(){ - it('should use the uiRoute property', function(){ - compileRoute('<div ui-route="/foo">'); - }); - it('should update model on $observe', function(){ - setPath('/bar'); - scope.$apply('foobar = "foo"'); - compileRoute('<div ui-route="/{{foobar}}">'); - expect(scope[modelProp]).toBeFalsy(); - scope.$apply('foobar = "bar"'); - expect(scope[modelProp]).toBe(true); - scope.$apply('foobar = "foo"'); - expect(scope[modelProp]).toBe(false); - }); - it('should support regular expression', function(){ - setPath('/foo/123'); - compileRoute('<div ui-route="/foo/[0-9]*">'); - expect(scope[modelProp]).toBe(true); - }); - }); - - describe('with ngHref defined', function(){ - - it('should use the ngHref property', function(){ - setPath('/foo'); - compileRoute('<a ng-href="/foo" ui-route>'); - expect(scope[modelProp]).toBe(true); - }); - it('should update model on $observe', function(){ - setPath('/bar'); - scope.$apply('foobar = "foo"'); - compileRoute('<a ng-href="/{{foobar}}" ui-route>'); - expect(scope[modelProp]).toBeFalsy(); - scope.$apply('foobar = "bar"'); - expect(scope[modelProp]).toBe(true); - scope.$apply('foobar = "foo"'); - expect(scope[modelProp]).toBe(false); - }); - }); - - describe('with href defined', function(){ - - it('should use the href property', function(){ - setPath('/foo'); - compileRoute('<a href="/foo" ui-route>'); - expect(scope[modelProp]).toBe(true); - }); - }); - - it('should throw an error if no route property available', function(){ - expect(function(){ - compileRoute('<div ui-route>'); - }).toThrow(); - }); - - it('should update model on route change', function(){ - setPath('/bar'); - compileRoute('<div ui-route="/foo">'); - expect(scope[modelProp]).toBeFalsy(); - setPath('/foo'); - expect(scope[modelProp]).toBe(true); - setPath('/bar'); - expect(scope[modelProp]).toBe(false); - }); - } -}); |