Skip to content

Commit c1096e1

Browse files
committed
Added unit test.
Tested if the hash is accessible in a $stageChangeStart hook.
1 parent d557cfc commit c1096e1

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

test/stateSpec.js

+12
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,18 @@ describe('state', function () {
570570
expect($location.url()).toBe('/front/world#frag');
571571
expect($location.hash()).toBe('frag');
572572
}));
573+
574+
it('has access to the #fragment in $stateChangeStart hook', inject(function ($state, $q, $location, $rootScope) {
575+
var hash_accessible = false;
576+
$rootScope.$on('$stateChangeStart', function (event, toState, toParams, fromState, fromParams) {
577+
hash_accessible = toParams['#'] === 'frag';
578+
});
579+
580+
$state.transitionTo('home.item', {id: 'world', '#': 'frag'});
581+
$q.flush();
582+
583+
expect(hash_accessible).toBe(true);
584+
}));
573585
});
574586

575587
describe('.go()', function () {

0 commit comments

Comments
 (0)