samedi 20 janvier 2018

How to create KeyboardEvent using Typescript in IE and PhantomJS

I am using Angular2 and have a method that takes a KeyboardEvent object. I would like to write tests for this method (using Karma and Jasmine if that matters).

I wrote some using the KeyboardEvent constructor which worked fine in Chrome, but fails in IE and PhantomJS. Is there a way to do it that will work in these browsers?

Method signature:

public onDateKeypress(evt: KeyboardEvent): boolean {
    // ...
}

Current test example:

let ke = new KeyboardEvent("keypress", { "key": "" + i, });
onDateKeypress(ke);

Aucun commentaire:

Enregistrer un commentaire