Created
April 4, 2012 16:20
-
-
Save dmt/2303459 to your computer and use it in GitHub Desktop.
jasmine clock example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | |
}); | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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