mardi 29 mars 2016

How can I test an angularjs factory using karma jasmine

I want to test a factory using Karma/Jasmine, Here is the code:

.factory('AuthenticationService',
['Base64', '$http', '$cookieStore', '$rootScope',
function (Base64, $http, $cookieStore, $rootScope) {
    var service = {};
    service.Login = function (email, password, callback) {
        /* Use this for real authentication
        ----------------------------------------------*/
        var parameter = JSON.stringify(
        {
            email: email,
            password: password
        });

        $http.post('http://ift.tt/1VRtvBL',parameter)
        .success(function (response) {
            callback(response);
        })
        .error(function (response) {
            callback(response);
        });

    };

    return service;
}]);

can you help me please. (Base64 is another factory)

Aucun commentaire:

Enregistrer un commentaire