Skip to content

Instantly share code, notes, and snippets.

@dmt
Created April 4, 2012 16:20
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 dmt/2303459 to your computer and use it in GitHub Desktop.
Save dmt/2303459 to your computer and use it in GitHub Desktop.
jasmine clock example
describe("ToolTip async", function () {
beforeEach(function () {
setFixtures("<form action='#'><input name='foo' type='text' /></form>");
// putting the implementation here for brevity
$(':input').on("focus", function () {
setTimeout(function () {
$("<div class='tooltip'>Some Tooltip</div>").prependTo('form');
}, 200);
});
});
it("shows some tooltip if focusing input fields", function () {
$(':input').trigger('focus');
waitsFor(function () {
return $('.tooltip').is(':visible');
});
runs(function () {
expect($('.tooltip')).toBeVisible();
});
});
});
describe("ToolTip", function () {
beforeEach(function () {
setFixtures("<form action='#'><input name='foo' type='text' /></form>");
// putting implementation here for brevity
$(':input').on("focus", function () {
setTimeout(function () {
$("<div class='tooltip'>Some Tooltip</div>").prependTo('form');
}, 200);
});
// switch out async functions
jasmine.Clock.useMock();
});
it("shows some tooltip if focusing input fields", function () {
$(':input').trigger('focus');
jasmine.Clock.tick(500);
expect($('.tooltip')).toBeVisible();
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment