jeudi 1 septembre 2016

karma + jasmine - promise.then inside code not getting excuted

Using karma with Jasmine 2. when my tests run, the piece of code where i have the following promise.then does not get executed.

doScan(issue) {
        let packet = this.getPacket();
        this.setPacket(packet, function() {
            archiverService.scanIssue(packet.packetNumber, issue).then(response => {
                if (response.ok) {
                    let body = response.body;
                    this.processScanResponse(issue, body);
                } else {
                    this.onBadResponse(issue, response);
                }
            }).catch(error => {
                this.onException(issue, error);
            });
        }.bind(this));
    }

this will eventually end up updating my component state ( i am using react) and that's what i want to test, not the promise. so far all the examples i saw online deal with testing the promise itself. Is there a way i can make it work?

Aucun commentaire:

Enregistrer un commentaire