Browse files

Timeout called after the Stop even issue fixed

  • Loading branch information...
1 parent c42898f commit 1d75055d56cd6a0caed5b0ef33a3b095ec8be81f @arunoda committed Apr 10, 2011
Showing with 34 additions and 6 deletions.
  1. +7 −5 lib/qbox.js
  2. +1 −1 package.json
  3. +26 −0 tests/qbox.js
View
12 lib/qbox.js
@@ -47,11 +47,13 @@ function QBox(steps) {
*/
this.timeout = function(amount, callback) {
- setTimeout(function() {
- if(!isReady) {
- callback(steps);
- }
- }, amount);
+ if(!isStop) {
+ setTimeout(function() {
+ if(!isReady && !isStop) {
+ callback(steps);
+ }
+ }, amount);
+ }
};
this.stop = function() {
View
2 package.json
@@ -1,6 +1,6 @@
{
"name": "qbox",
- "version": "0.1.1beta",
+ "version": "0.1.3",
"directories": {
"lib": "./lib"
},
View
26 tests/qbox.js
@@ -71,4 +71,30 @@ exports.testStopWithoutTick = function(test) {
});
test.done();
+};
+
+exports.testAfterStopTimeout = function(test) {
+
+ var $ = qbox.create();
+ $.stop();
+ $.timeout(1000, function() {
+ test.fail("Should not call the timeout");
+ });
+
+ setTimeout(function() {
+ test.done();
+ }, 1500);
+};
+
+exports.testBeforeStopTimeout = function(test) {
+
+ var $ = qbox.create();
+
+ $.timeout(1000, function() {
+ test.fail("Should not call the timeout");
+ });
+ $.stop();
+ setTimeout(function() {
+ test.done();
+ }, 1500);
};

0 comments on commit 1d75055

Please sign in to comment.