forked from angular-ui/ui-router
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstateFiltersSpec.js
48 lines (42 loc) · 1.64 KB
/
stateFiltersSpec.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
describe('isState filter', function() {
beforeEach(module('ui.router'));
beforeEach(module(function($stateProvider) {
$stateProvider
.state('a', { url: '/' })
.state('a.b', { url: '/b' });
}));
it('should return true if the current state exactly matches the input state', inject(function($parse, $state, $q, $rootScope) {
$state.go('a');
$q.flush();
expect($parse('"a" | isState')($rootScope)).toBe(true);
}));
it('should return false if the current state does not exactly match the input state', inject(function($parse, $q, $state, $rootScope) {
$state.go('a.b');
$q.flush();
expect($parse('"a" | isState')($rootScope)).toBe(false);
}));
});
describe('includedByState filter', function() {
beforeEach(module('ui.router'));
beforeEach(module(function($stateProvider) {
$stateProvider
.state('a', { url: '/' })
.state('a.b', { url: '/b' })
.state('c', { url: '/c' });
}));
it('should return true if the current state exactly matches the input state', inject(function($parse, $state, $q, $rootScope) {
$state.go('a');
$q.flush();
expect($parse('"a" | includedByState')($rootScope)).toBe(true);
}));
it('should return true if the current state includes the input state', inject(function($parse, $state, $q, $rootScope) {
$state.go('a.b');
$q.flush();
expect($parse('"a" | includedByState')($rootScope)).toBe(true);
}));
it('should return false if the current state does not include input state', inject(function($parse, $state, $q, $rootScope) {
$state.go('c');
$q.flush();
expect($parse('"a" | includedByState')($rootScope)).toBe(false);
}));
});