[CB-462] added a watchaccel test for frequency callback invocation
Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/commit/47d1ee75 Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/tree/47d1ee75 Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/diff/47d1ee75 Branch: refs/heads/462 Commit: 47d1ee758cc1b9ca67effc91b4301482ed484411 Parents: 0463f1b Author: Fil Maj <maj....@gmail.com> Authored: Fri May 18 13:42:24 2012 -0700 Committer: Fil Maj <maj....@gmail.com> Committed: Fri May 18 13:42:24 2012 -0700 ---------------------------------------------------------------------- test/test.accelerometer.js | 20 ++++++++++++++++++++ 1 files changed, 20 insertions(+), 0 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/47d1ee75/test/test.accelerometer.js ---------------------------------------------------------------------- diff --git a/test/test.accelerometer.js b/test/test.accelerometer.js index f424938..085fa74 100644 --- a/test/test.accelerometer.js +++ b/test/test.accelerometer.js @@ -117,6 +117,26 @@ describe("accelerometer", function () { expect(success).toHaveBeenCalled(); }); }); + it("should fire the success callback on the appropriate interval, not based on how quickly the framework returns accel objects", function() { + var success = jasmine.createSpy(); + runs(function() { + id = accelerometer.watchAcceleration(success, function(){}, {frequency:250}); + }); + waits(25); + runs(function() { + callSuccess(); + expect(success).not.toHaveBeenCalled(); + }); + waits(25); + runs(function() { + callSuccess(); + expect(success).not.toHaveBeenCalled(); + }); + waits(210); + runs(function() { + expect(success).toHaveBeenCalled(); + }); + }); }); });