Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

fix(ngMock): attach $injector to $rootElement #14034

Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/ngMock/angular-mocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -2089,9 +2089,9 @@ angular.mock.$RAFDecorator = ['$delegate', function($delegate) {
*
*/
angular.mock.$RootElementProvider = function() {
this.$get = function() {
return angular.element('<div ng-app></div>');
};
this.$get = ['$injector', function($injector) {
return angular.element('<div ng-app></div>').data('$injector', $injector);
}];
};

/**
Expand Down
4 changes: 4 additions & 0 deletions test/ngMock/angular-mocksSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1647,6 +1647,10 @@ describe('ngMock', function() {
it('should create mock application root', inject(function($rootElement) {
expect($rootElement.text()).toEqual('');
}));

it('should attack the `$injector` to `$rootElement`', inject(function($injector, $rootElement) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

attack -> attach

expect($rootElement.injector()).toBe($injector);
}));
});


Expand Down