Skip to content

Commit eb7c3ab

Browse files
hshnchristopherthielen
authored andcommitted
test(viewDirective): added controller injection test
cherry pick c5249bb from 1.0
1 parent b401b84 commit eb7c3ab

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

test/viewDirectiveSpec.js

+15
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,12 @@ describe('uiView', function () {
103103
}
104104
}
105105
},
106+
mState = {
107+
template: 'mState',
108+
controller: function ($scope, $element) {
109+
$scope.elementId = $element.attr('id');
110+
}
111+
},
106112
nState = {
107113
template: 'nState',
108114
controller: function ($scope, $element) {
@@ -128,6 +134,7 @@ describe('uiView', function () {
128134
.state('j', jState)
129135
.state('k', kState)
130136
.state('l', lState)
137+
.state('m', mState)
131138
.state('n', nState)
132139
}));
133140

@@ -323,6 +330,14 @@ describe('uiView', function () {
323330
expect(elem.text()).toBe('value');
324331
}));
325332

333+
it('should instantiate a controller with both $scope and $element injections', inject(function ($state, $q) {
334+
elem.append($compile('<div><ui-view id="mState">{{elementId}}</ui-view></div>')(scope));
335+
$state.transitionTo(mState);
336+
$q.flush();
337+
338+
expect(elem.text()).toBe('mState');
339+
}));
340+
326341
describe('play nicely with other directives', function() {
327342
// related to issue #857
328343
it('should work with ngIf', inject(function ($state, $q, $compile) {

0 commit comments

Comments
 (0)