Skip to content

Commit 54e40b1

Browse files
test(params): Test that param objects are shallowly copied and can contain $scope
Closes ui-router/core#74
1 parent 2f7a3f2 commit 54e40b1

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

test/stateSpec.js

+14
Original file line numberDiff line numberDiff line change
@@ -1413,6 +1413,18 @@ describe('state', function () {
14131413
expect($state.current.name).toBe("about");
14141414
}));
14151415

1416+
// test for https://github.com/ui-router/core/issues/74
1417+
it('should allow param objects containing $scope', inject(function ($state, $q, $rootScope, $transitions) {
1418+
var errorhandler = jasmine.createSpy('errorhandler');
1419+
$state.defaultErrorHandler(errorhandler);
1420+
1421+
$state.go('types', { nonurl: { errorscope: $rootScope } });
1422+
$q.flush();
1423+
1424+
expect(errorhandler).not.toHaveBeenCalled();
1425+
expect($state.params.nonurl && $state.params.nonurl.errorscope).toBe($rootScope);
1426+
}));
1427+
14161428
function expectStateUrlMappingFn($state, $rootScope, $q, $location) {
14171429
return function (state, url, params, defaults, nonurlparams) {
14181430
$state.go(state, extend({}, nonurlparams, params));
@@ -1937,10 +1949,12 @@ describe('$stateParams', function () {
19371949
it('should start empty', inject(function ($stateParams) {
19381950
expect($stateParams.foo).toBeUndefined();
19391951
}));
1952+
19401953
it('should allow setting values on it', inject(function ($stateParams) {
19411954
$stateParams.foo = 'bar';
19421955
expect($stateParams.foo).toBeDefined();
19431956
}));
1957+
19441958
it('should be cleared between tests', inject(function ($stateParams) {
19451959
expect($stateParams.foo).toBeUndefined();
19461960
}));

0 commit comments

Comments
 (0)