mardi 10 octobre 2017

Angular 4 Unit Testing the code using window

I would like to test a code

public openAttachment(attachment: CIMAttachment) {
    if (window.navigator && window.navigator.msSaveOrOpenBlob) {
        window.navigator.msSaveOrOpenBlob(attachment.getFile());
    }
    else {
        let objectUrl = URL.createObjectURL(attachment.getFile());
        window.open(objectUrl);
    }
}

I don't know how to get access to window or mock window in order to test it. I'm new to angular testing so it would be great if you could explain me in a detail please!

Aucun commentaire:

Enregistrer un commentaire