vendredi 27 février 2015

AngularJS Jasmine Factory test

I'm trying to test a Factory with Jasmine but I'm getting:


Error: [$injector:unpr] Unknown provider: Provider <- <- RecaptchaFactory


Here is my factory:



(function() {
'use strict';

angular
.module('app')
.factory('RecaptchaFactory', Recaptcha);

Recaptcha.$inject = [''];

function Recaptcha() {
return {
passwordAttempts: passwordAttempts,
};

var passwordAttempts = 0;

}
})();


And my test:



describe("RecaptchaFactory", function(){
beforeEach(module("app"));

var factory;

beforeEach(inject(function(RecaptchaFactory){
factory = RecaptchaFactory;
}));

describe("init", function(){
it("should init passwordAttempts with 0", function(){
expect(factory.passwordAttempts).toBe(0);
});
});
});

Aucun commentaire:

Enregistrer un commentaire