Skip to content

Commit 7ef4d77

Browse files
committed
chore(tests): ensuring version compatibility
- Misc. cleanup.
1 parent 427b7f8 commit 7ef4d77

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

src/stateDirectives.js

-2
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,7 @@ function $StateRefDirective($state, $timeout) {
9090
if ((button === 0 || button == 1) && !e.ctrlKey && !e.metaKey && !e.shiftKey && !element.attr('target')) {
9191
// HACK: This is to allow ng-clicks to be processed before the transition is initiated:
9292
$timeout(function() {
93-
scope.$apply(function() {
9493
$state.go(ref.state, params, { relative: base });
95-
});
9694
});
9795
e.preventDefault();
9896
}

test/stateDirectivesSpec.js

+14-7
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,22 @@ describe('uiStateRef', function() {
5353
}
5454

5555
describe('links with promises', function() {
56+
5657
it('should update the href when promises on parameters change before scope is applied', inject(function($rootScope, $compile, $q) {
57-
promise = $q.defer()
58+
var defer = $q.defer();
5859
el = angular.element('<a ui-sref="contacts.item.detail({ id: contact.id })">Details</a>');
59-
scope = $rootScope;
60-
scope.contact = promise.promise;
61-
promise.resolve({id: 6});
62-
scope.$apply();
63-
$compile(el)(scope);
64-
scope.$digest();
60+
61+
$rootScope.contact = defer.promise;
62+
defer.resolve({ id: 6 });
63+
64+
$compile(el)($rootScope);
65+
$rootScope.$digest();
66+
67+
// HACK: Promises no longer auto-unwrap in 1.2.x+
68+
if ($rootScope.contact.$$resolved && $rootScope.contact.$$resolved.value) {
69+
$rootScope.contact = $rootScope.contact.$$resolved.value;
70+
$rootScope.$digest();
71+
}
6572

6673
expect(el.attr('href')).toBe('#/contacts/6');
6774
}));

0 commit comments

Comments
 (0)