jeudi 21 janvier 2016

Testing if an event has been triggered in Jasmine

How do you test if an event has been fired in Jasmine without jquery-jasmine?

I'm working on a project where we don't use jQuery (wohoo), and I'm trying to write a unit test for my menu triggering function. It works like this:

  • You click a button
  • My testable component then runs document.dispatchEvent(new CustomEvent('menu.toggle'))
  • I want to test that the component indeed dispatched the custom event.

How do I test this?

Aucun commentaire:

Enregistrer un commentaire