lundi 27 avril 2015

Why unit testing response is always successful?

I was reading posts related for don't repeat the question.

I have the next unit testing code:

describe('service', function() {
var questionApiService;

beforeEach(module('myApp'));

beforeEach(inject(function (_questionApiService_) {
    questionApiService = _questionApiService_;
}));

// Test service availability
it('check the existence of get field question service', inject(function(questionApiService) {
//expect(1).toEqual(100);

    questionApiService.getField()
        .then(function(data) {

            //console.log(data);
            expect(1).toEqual(100);
        });
}));

});

If I run the code expect(1).toEqual(100); outside the service, the result is Error, but if I write the same code expect(1).toEqual(100); inside the service, the result is Success, which makes me think that the validator is not entering the service.

Whats wrong?

Aucun commentaire:

Enregistrer un commentaire