Skip to content

Commit c5249bb

Browse files
committed
test(viewDirective): added controller injection test
1 parent 4c03164 commit c5249bb

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
@@ -97,6 +97,12 @@ describe('uiView', function () {
9797
template: 'view3'
9898
}
9999
}
100+
},
101+
mState = {
102+
template: 'mState',
103+
controller: function ($scope, $element) {
104+
$scope.elementId = $element.attr('id');
105+
}
100106
};
101107

102108
beforeEach(module(function ($stateProvider) {
@@ -113,6 +119,7 @@ describe('uiView', function () {
113119
.state('j', jState)
114120
.state('k', kState)
115121
.state('l', lState)
122+
.state('m', mState)
116123
}));
117124

118125
beforeEach(inject(function ($rootScope, _$compile_) {
@@ -307,6 +314,14 @@ describe('uiView', function () {
307314
expect(elem.text()).toBe('value');
308315
}));
309316

317+
it('should instantiate a controller with both $scope and $element injections', inject(function ($state, $q) {
318+
elem.append($compile('<div><ui-view id="mState">{{elementId}}</ui-view></div>')(scope));
319+
$state.transitionTo(mState);
320+
$q.flush();
321+
322+
expect(elem.text()).toBe('mState');
323+
}));
324+
310325
describe('play nicely with other directives', function() {
311326
// related to issue #857
312327
it('should work with ngIf', inject(function ($state, $q, $compile) {

0 commit comments

Comments
 (0)