Skip to content

Instantly share code, notes, and snippets.

@kyeh
Last active August 29, 2015 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kyeh/3cc0c4c8a736875f35b0 to your computer and use it in GitHub Desktop.
Save kyeh/3cc0c4c8a736875f35b0 to your computer and use it in GitHub Desktop.
test_hide_doubleclick.js
test("Hide called only once if triggered multiple times", function(){
var deferred = $.Deferred();
this.mock($.prototype).expects('hide')
.withArgs(2000)
.once() // this once assertion will verify hide was called only once during the test
.returns(deferred);
hideLink();
QUnit.equal($('#hide-status').text(), 'Link hiding in-progress');
hideLink(); //runs the second time after .hide() was called
deferred.resolve();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment