Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat($IncludedByStateFilter): add parameters to $IncludedByStateFilter #2193

Merged
merged 1 commit into from
Dec 8, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/state/stateFilters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ export function $IsStateFilter($state) {
*/
$IncludedByStateFilter.$inject = ['$state'];
export function $IncludedByStateFilter($state) {
return function(state) {
return $state.includes(state);
return function(state, params, options) {
return $state.includes(state, params, options);
};
}

Expand Down
15 changes: 14 additions & 1 deletion test/stateFiltersSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ describe('includedByState filter', function() {
$stateProvider
.state('a', { url: '/' })
.state('a.b', { url: '/b' })
.state('c', { url: '/c' });
.state('c', { url: '/c' })
.state('d', { url: '/d/:id' });
}));

it('should return true if the current state exactly matches the input state', inject(function($parse, $state, $q, $rootScope) {
Expand All @@ -48,4 +49,16 @@ describe('includedByState filter', function() {
$q.flush();
expect($parse('"a" | includedByState')($rootScope)).toBe(false);
}));

it('should return true if the current state include input state and params', inject(function($parse, $state, $q, $rootScope) {
$state.go('d', { id: 123 });
$q.flush();
expect($parse('"d" | includedByState:{ id: 123 }')($rootScope)).toBe(true);
}));

it('should return false if the current state does not include input state and params', inject(function($parse, $state, $q, $rootScope) {
$state.go('d', { id: 2377 });
$q.flush();
expect($parse('"d" | includedByState:{ id: 123 }')($rootScope)).toBe(false);
}));
});