lundi 30 novembre 2015

angularjs how to call service method inside jasmine unit test

I'm wanting to call a service method inside my jasmine unit test. I've been looking around and there are many ways, it seems to call a method that returns a promise.I'd like to call the service method and read the response back or at least test it. Whats the best way to call the service and get back the response in my unit test?

describe("can I call a service method  ", function () {
        var getMyservice;

        beforeEach(function(){
            module(moduleName);
            module('myservice.dependency');
            inject(function($injector, _$controller_, _$rootScope_){
                $controller = _$controller_;
                $rootScope = _$rootScope_;
                getMyservice = $injector.get('getMyservice');
            });
        });

        it("getMyservice should be defined", function () {
            expect(getMyservice).toBeUndefined();
        });



    });

Aucun commentaire:

Enregistrer un commentaire