vendredi 29 avril 2016

How to use a function defined in service in another controller in angularjs unit test

I have a function called 'functionA' in service called ServiceA maybe:

return Restangular
    .extendModel('modelA', function(model) {
            model.functionA = function(body) {
                return this.customPUT(body, 'add')
            };
            return model;
    })
    .service('accounts');

And I can use it in ControllerB, it works well.

function functionB(body){
    instanceModelB.instanceModelA.functionA(body)
            .then(onSuccess)
            .catch(onFail)
            .finally(onFinally);
}

But How to use it in the unit test for ControllerB? I mean how to call functionA in unit test for ControllerB? It always says 'functionA is not a function'. Thanks in advance.

Aucun commentaire:

Enregistrer un commentaire