Get new jQuery plugins just once a week
September 11, 2012
- SpiesTesting any function can be quite elegantly achieved with a test spy.
- StubsThe function returned by once should return whatever the original function returns. To test this, we create a stub.
- Testing AjaxTheres a function that triggers network activity.
- Fake XMLHttpRequestWhile the preceding test shows off some nifty Sinon.JS tricks, it is too tightly coupled to the implementation. When testing Ajax, it is better to use Sinon.JS’ fake XMLHttpRe:uest.
- Fake serverThe preceding example shows how flexible this API is. If it looks too laborous, you may like the fake server.
- Faking timeTesting time-sensitive logic without the wait is a breeze with Sinon.JS. The following function throttles another function – only when it has not been called for 100 milliseconds will it call the original function with the last set of arguments it received.
Created by Christian Johansen
Sign up for our weekly newsletter.
10 Most Amazing Couple Gifts
A comprehensive guide to couple gift Ideas for Valentine’s Day, Weddings, Anniversaries for your spouse, friend, fiance, boyfriend / girlfriend.
Take me there !
Continue to jquer.in