class Router {
constructor() {
window.onhashchange = this.hashChange;
}
hashChange() {
console.log('Hash Changed');
return true;
}
}
export default Router;
I am trying to find a way to test the above piece of code in node.js. But there is no window
object in node. How to mock objects and test event listeners using mocha/jest? The goal is to test that hashChange()
is invoked when URL hash is changed
Aucun commentaire:
Enregistrer un commentaire