mercredi 1 juillet 2015

How to test promise in jasmine & karma

I have a test case as follow:

it("Should have a valid structure", function(done){ 

    var data;
    module(APP_MODULE_NAME);

    inject(function(_metaService_){
        metaService = _metaService_;            
    });

    metaService.fetchEntityMeta('person').then(function(data){
        expect(data.status).toBe( true );
    });

});

But i am getting following error:

Error: timeout of 2000ms exceeded. Ensure the done() callback is being called in this test.

I have increased jasmine.DEFAULT_TIMEOUT_INTERVAL but not use. But following code does work.

    setTimeout(function(){
        expect(true).toBe(true);
        done();
    }, 5000);

So, my understanding is I am having problem with promise. My question is how can i check the data returned by the promise.

Aucun commentaire:

Enregistrer un commentaire