Skip to content

Commit facf613

Browse files
committed
test($state): tests that resolves inject $transition$
Refs. #1018
1 parent 2573cec commit facf613

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

test/stateSpec.js

+17-1
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,17 @@ describe('state', function () {
276276
.state('OPT.OPT2', OPT2)
277277
.state('home', { url: "/" })
278278
.state('home.item', { url: "front/:id" })
279-
.state('about', { url: "/about" })
279+
.state('about', {
280+
url: "/about",
281+
resolve: {
282+
stateInfo: function($transition$) {
283+
return [$transition$.from().name, $transition$.to().name];
284+
}
285+
},
286+
onEnter: function(stateInfo) {
287+
log = stateInfo.join(' => ');
288+
}
289+
})
280290
.state('about.person', { url: "/:person" })
281291
.state('about.person.item', { url: "/:id" })
282292
.state('about.sidebar', {})
@@ -709,6 +719,12 @@ describe('state', function () {
709719
expect($location.url()).toBe('/front/world#frag');
710720
expect($location.hash()).toBe('frag');
711721
}));
722+
723+
it('injects $transition$ into resolves', inject(function ($state, $q) {
724+
$state.transitionTo('home'); $q.flush();
725+
$state.transitionTo('about'); $q.flush();
726+
expect(log).toBe('home => about');
727+
}));
712728
});
713729

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

0 commit comments

Comments
 (0)