|
| 1 | +describe('isState filter', function() { |
| 2 | + beforeEach(module('ui.router')); |
| 3 | + beforeEach(module(function($stateProvider) { |
| 4 | + $stateProvider |
| 5 | + .state('a', { url: '/' }) |
| 6 | + .state('a.b', { url: '/b' }); |
| 7 | + })); |
| 8 | + |
| 9 | + it('should return true if the current state exactly matches the input state', inject(function($parse, $state, $q, $rootScope) { |
| 10 | + $state.go('a'); |
| 11 | + $q.flush(); |
| 12 | + expect($parse('"a" | isState')($rootScope)).toBe(true); |
| 13 | + })); |
| 14 | + |
| 15 | + it('should return false if the current state does not exactly match the input state', inject(function($parse, $q, $state, $rootScope) { |
| 16 | + $state.go('a.b'); |
| 17 | + $q.flush(); |
| 18 | + expect($parse('"a" | isState')($rootScope)).toBe(false); |
| 19 | + })); |
| 20 | +}); |
| 21 | + |
| 22 | +describe('includedByState filter', function() { |
| 23 | + beforeEach(module('ui.router')); |
| 24 | + beforeEach(module(function($stateProvider) { |
| 25 | + $stateProvider |
| 26 | + .state('a', { url: '/' }) |
| 27 | + .state('a.b', { url: '/b' }) |
| 28 | + .state('c', { url: '/c' }); |
| 29 | + })); |
| 30 | + |
| 31 | + it('should return true if the current state exactly matches the input state', inject(function($parse, $state, $q, $rootScope) { |
| 32 | + $state.go('a'); |
| 33 | + $q.flush(); |
| 34 | + expect($parse('"a" | includedByState')($rootScope)).toBe(true); |
| 35 | + })); |
| 36 | + |
| 37 | + it('should return true if the current state includes the input state', inject(function($parse, $state, $q, $rootScope) { |
| 38 | + $state.go('a.b'); |
| 39 | + $q.flush(); |
| 40 | + expect($parse('"a" | includedByState')($rootScope)).toBe(true); |
| 41 | + })); |
| 42 | + |
| 43 | + it('should return false if the current state does not include input state', inject(function($parse, $state, $q, $rootScope) { |
| 44 | + $state.go('c'); |
| 45 | + $q.flush(); |
| 46 | + expect($parse('"a" | includedByState')($rootScope)).toBe(false); |
| 47 | + })); |
| 48 | +}); |
0 commit comments