ramda / repl

The Ramda REPL
34 stars 15 forks source link

Fix failing tests (#56) #57

Closed seanpoulter closed 5 years ago

seanpoulter commented 6 years ago

As reported in #55, two tests have been failing when running locally. Investigation has shown that the change event handler in bindInputPanel is not called. Despite the tests waiting twice the debouncing delay, the debounced function is not called.

The root cause of the test failures is the fake timers are not applying to the now() call in the debounce library. Based on the docs for fake timers, calling sinon.useFakeTimers() should:

Starts the clock at the UNIX epoch (timestamp of 0).

After calling clock.tick(ms) we should see ms, but instead we get the current timestamp (below highlighted variable on mid left):

screen shot 2018-04-15 at 23 43 08

Changing the order of the imports ensures that debounce and date-now use the fake timers, and the tests pass. With the changes in this PR, notice how the timestamp is our value for clock.tick(ms):

screen shot 2018-04-15 at 23 57 12

Those failing tests pass:

screen shot 2018-04-15 at 23 59 03
seanpoulter commented 6 years ago

This should fix those tests @buzzdecafe and close #56.

Heads up, I accidentally created the PR before finishing my notes. Take a look on GitHub if your notification email didn't make sense. 😉

buzzdecafe commented 6 years ago

wow that's all there was too it? Very nice catch, @seanpoulter . I wanna verify on my local tonight, then will merge. Thanks. (sinon often feels a bit too magical for me.)