dimanche 7 août 2016

[$injector:unpr Unknown provider: GammeProvider <- Gamme <- GammeEditCtrl

Hello I am writing my first angular test with Jasmine but I keep getting the error here is my controller

(function () {
    'use strict';
    var dependencies = [];
    angular.module('entityEdit', dependencies)
            .config(configFn)
            .run(runFn)
            .directive('entityEdit', ['BASE_PATH', entityEditDirective])
            .controller('EntityEditCtrl', ['$scope', '$rootScope','Entity', EntityEditCtrl])

    function EntityEditCtrl($scope, $rootScope,Entity) {
        $scope.entity = {};
        $scope.list=[
            {'id':"1",'libelle':'A' },
            {'id':"2",'libelle':'B' },
        ]
        $rootScope.$on('Entity_LIST_SELECTED', function (event, data) {
            console.log("received");
            $scope.entity = data;
        });
        $scope.save= saveFn;             
        function saveFn()
        {
            console.log("savefn");
            console.log($scope.entity);
            Entity.updateEntity($scope.entity);
        }
    }
    function runFn() {
        console.log('Run : entityEdit');
    }
    function configFn() {
        console.log('Config : entityEdit');
    }
})();

and here is my jasmine test

describe('EntityEditCtrl', function () {
    var $rootScope, scope, $controller;
    beforeEach(angular.mock.module('entityEdit'));
    beforeEach(inject(function ($rootScope, $controller) {
        scope = $rootScope.$new();
        $controller('EntityEditCtrl', {
        $scope: scope
    });     
    ctrl = $controller('EntityEditCtrl',function(){});
    }));    
    it('exists',inject(function($controller){   
             expect(ctrl).toBeDefined();    
             expect(ctrl).not.toBeNull();
             expect(typeof ctrl).toBe('object');
    }));
});

If you see the problem please let me know

Aucun commentaire:

Enregistrer un commentaire