jameslnewell / xhr-mock

Utility for mocking XMLHttpRequest.
197 stars 48 forks source link

addEventListener support #15

Closed christianalfoni closed 7 years ago

christianalfoni commented 7 years ago

Hi there!

Great work on this library. I have added addEventListener and removeEventListener compatibility.

I also added a progress method to MockRequest to allow you to trigger progress events.

jameslnewell commented 7 years ago

Thanks for the PR!

Does the current API allow (and does it need to allow) for triggering multiple progress events?

MockXMLHttpRequest.addHandler(function(req, res) {
  req.progress(50, 100)
  return res
});

Otherwise looks great.

christianalfoni commented 7 years ago

Hi there @jameslnewell ,

Yes, you can call progress method multiple times. It just triggers the progress event with the values passed in :)

jameslnewell commented 7 years ago

@christianalfoni thanks for the great addition! Released in xhr-mock@1.7.0