[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/2058df76 Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/tree/2058df76 Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/diff/2058df76 Branch: refs/heads/master Commit: 2058df7613b652e37f305308c1e4602b470d43d3 Parents: 4f40099 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 15:14:37 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/2058df76/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(); + }); + }); }); });