mercredi 27 juillet 2016

Protractor, mocking API calls

I am following this tutorial. http://ift.tt/1s1DFCs

so in my mock.js

exports.signin_request = function(){
    var expected_response = ('1 - noor.alhabbal@gmail.com')
    angular.module('httpBackendMock', ['userManagement', 'ngMockE2E'])
        .run(function ($httpBackend) {
            $httpBackend.whenGET('http://ift.tt/2agiV6q').respond(function(){
                return [200, expected_response];
            });
            // $httpBackend.whenGET(/.*/).passThrough();
    });
}

and in my function

it('should check if the api is working and returns correct login value',function()
    {
        browser.addMockModule('httpBackendMock', mockModule.signin_request);  

        expect (mockModule.signin_request).toEqual[200,'user@gmail.com']
    })

the API returns the email if it's valid or the word error if it's not. My expect statement is wrong. How can I fix it to make sure that what I got back is "user@gmail.com"

Aucun commentaire:

Enregistrer un commentaire