From b7202cbd05692cb16722bdff6337009fd8b33c59 Mon Sep 17 00:00:00 2001 From: Lisa Pfisterer Date: Wed, 1 Nov 2017 18:26:04 +0000 Subject: [PATCH] docs(guide/Unit Testing): Changed $scope = {} to $scope = $rootScope.$new() {} will just create an empty object. This will break if the module uses for example $watch or others. --- docs/content/guide/unit-testing.ngdoc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/docs/content/guide/unit-testing.ngdoc b/docs/content/guide/unit-testing.ngdoc index 63f1b8667da4..cc689a23473b 100644 --- a/docs/content/guide/unit-testing.ngdoc +++ b/docs/content/guide/unit-testing.ngdoc @@ -149,16 +149,17 @@ for instantiating controllers. describe('PasswordController', function() { beforeEach(module('app')); - var $controller; + var $controller, $rootScope; - beforeEach(inject(function(_$controller_){ + beforeEach(inject(function(_$controller_, _$rootScope_){ // The injector unwraps the underscores (_) from around the parameter names when matching $controller = _$controller_; + $rootScope = _$rootScope_; })); describe('$scope.grade', function() { it('sets the strength to "strong" if the password length is >8 chars', function() { - var $scope = {}; + var $scope = $rootScope.$new(); var controller = $controller('PasswordController', { $scope: $scope }); $scope.password = 'longerthaneightchars'; $scope.grade();