angular-inject-into

1.0.2 • Public • Published

angular-inject-into

Angular injection into an object. DRY and minification-safe. E.g. to simplify angular.mock.inject beforeEach assignment boilerplate in Jasmine tests.

You can now do this:

describe('test', function () {
  var inj = {};
 
  beforeEach(inject(injectInto(['$rootScope', '$http', '$location'], inj)));
 
  it('inject', function () {
    expect(inj.$rootScope).toBeDefined();
    expect(inj.$http).toBeDefined();
    expect(inj.$location).toBeDefined();
  });
});

Instead of this:

describe('test', function () {
  var $rootScope;
  var $http;
  var $location;
 
  beforeEach(inject(function (_$rootScope_, _$http_, _$location_) {
    $rootScope = _$rootScope_;
    $http = _$http_;
    $location = _$location_;
  }));
 
  it('inject', function () {
    expect($rootScope).toBeDefined();
    expect($http).toBeDefined();
    expect($location).toBeDefined();
  });
});

Package Sidebar

Install

npm i angular-inject-into

Weekly Downloads

3

Version

1.0.2

License

ISC

Unpacked Size

3.67 kB

Total Files

5

Last publish

Collaborators

  • adjohnson916