Repository: angular/angular.js
File: test/auto/injectorSpec.js (JavaScript)

Code before:


    it('should be able to register a controller from a new module', function() {
      var injector = createInjector(['ng']);
      angular.module('a', []);
      angular.module('a').controller('aController', function($scope) {
        $scope.test = 'b';
      });
      injector.loadNewModules(['a']);
      injector.invoke(function($controller) {
        var scope = {};
        $controller('aController', {$scope: scope});
        expect(scope.test).toEqual('b');
      });
    });


    it('should be able to register a filter from a new module', function() {
      var injector = createInjector(['ng']);
      angular.module('a', []);
      angular.module('a').filter('aFilter', function() {
        return function(input) { return input + ' filtered'; };
      });
      injector.loadNewModules(['a']);
      injector.invoke(function($filter) {
        var filter = $filter('aFilter');
        expect(filter('test')).toEqual('test filtered');
      });
    });


    it('should be able to register a directive from a new module', function() {
      var injector = createInjector(['ng']);
      angular.module('a', []);
      angular.module('a').directive('aDirective', function() {
        return {  template: 'test directive' };
      });
      injector.loadNewModules(['a']);
      injector.invoke(function($compile, $rootScope) {
        var scope = $rootScope.$new();
        var html = '<div a-directive></div>';
        var elem = angular.element(html);
        $compile(elem)(scope);  // compile and link
        scope.$digest();
        expect(elem.text()).toEqual('test directive');
        elem.remove();
      });
    });
  });

  it('should have a false strictDi property', inject(function($injector) {

Review comment (suggestion):
Save a line with `injector.invoke(function(aFilterFilter) {` :bowtie: 
(Bonus points for the hidden `filterFilter` reference 😛)

Code after:

    it('should be able to register a controller from a new module', function() {
      var injector = createInjector(['ng']);
      angular.module('a', []).controller('aController', function($scope) {
        $scope.test = 'b';
      });
      injector.loadNewModules(['a']);
      injector.invoke(function($controller) {
        var scope = {};
        $controller('aController', {$scope: scope});
        expect(scope.test).toEqual('b');
      });
    });


    it('should be able to register a filter from a new module', function() {
      var injector = createInjector(['ng']);
      angular.module('a', []).filter('aFilter', function() {
        return function(input) { return input + ' filtered'; };
      });
      injector.loadNewModules(['a']);
      injector.invoke(function(aFilterFilter) {
        expect(aFilterFilter('test')).toEqual('test filtered');
      });
    });


    it('should be able to register a directive from a new module', function() {
      var injector = createInjector(['ng']);
      angular.module('a', []).directive('aDirective', function() {
        return {template: 'test directive'};
      });
      injector.loadNewModules(['a']);
      injector.invoke(function($compile, $rootScope) {
        var elem = $compile('<div a-directive></div>')($rootScope);  // compile and link
        $rootScope.$digest();
        expect(elem.text()).toEqual('test directive');
        elem.remove();
      });
    });
  });

  it('should have a false strictDi property', inject(function($injector) {
    expect($injector.strictDi).toBe(false);
  }));


  describe('invoke', function() {
    var args;

    beforeEach(function() {