samedi 6 août 2016

Unknown provider in test case for angular with es6 module

I have to write karma-jasmine test case for controller

(->

class AddUserController
  @$inject = ['$scope', '$http', '$state', 'UserFactory']

  constructor: (@$scope, @$http, @$state, @OfficesService, UserFactory) ->
    @user = new UserFactory()



angular
.module('app', [])
.controller('AddUserController', AddUserController)
)()

but when I inject AddUserController in test case it gives me unknown provider:

describe('add_user_controller', function() {
  var addUserController, $httpBackend;

  beforeEach(module("app"));

  beforeEach(
    inject( function($injector, $rootScope) {
      addUserController = $injector.get('AddUserController')
    })
  );
  it('should have initialize values', function() {
    expect(addUserController.user).toBeDefined();
  })
});

Can any one guess, whats going wrong here.

Aucun commentaire:

Enregistrer un commentaire