diff --git a/Gruntfile.js b/Gruntfile.js index 36ef96c4..9d746526 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -96,7 +96,7 @@ module.exports = function(grunt) { 'saucelabs-qunit': { all: { options: { - urls: ["http://127.0.0.1:9999/test/index.html"], + urls: ["http://127.0.0.1:9999/test/index.html?hidepassed"], build: process.env.TRAVIS_JOB_ID, throttled: 3, "max-duration" : 600, // seconds, IE6 is slow diff --git a/lib/utils.js b/lib/utils.js index d79e0110..f61c0088 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -3,7 +3,7 @@ var support = require('./support'); var base64 = require('./base64'); var nodejsUtils = require('./nodejsUtils'); -var asap = require('asap'); +var setImmediate = require('core-js/library/fn/set-immediate'); var external = require("./external"); @@ -372,7 +372,7 @@ exports.pretty = function(str) { * @param {Array} args the arguments to give to the callback. */ exports.delay = function(callback, args, self) { - asap(function () { + setImmediate(function () { callback.apply(self || null, args || []); }); }; diff --git a/package.json b/package.json index 6f9ca109..1587194f 100644 --- a/package.json +++ b/package.json @@ -49,10 +49,10 @@ "tmp": "0.0.28" }, "dependencies": { + "core-js": "~2.3.0", "es6-promise": "~3.0.2", "pako": "~1.0.0", - "readable-stream": "~2.0.6", - "asap": "~2.0.3" + "readable-stream": "~2.0.6" }, "license": "(MIT OR GPL-3.0)" } diff --git a/test/asserts/stream.js b/test/asserts/stream.js index d7aec2fc..52f3385a 100644 --- a/test/asserts/stream.js +++ b/test/asserts/stream.js @@ -6,8 +6,8 @@ QUnit.module("stream", function () { QUnit.module("internal"); - test("A stream is pausable", function () { - // let's get a stream that generates a lot of chunks + test("A stream is pausable", function (assert) { + // let's get a stream that generates a lot of chunks (~40) var zip = new JSZip(); var txt = "a text"; for(var i = 0; i < 10; i++) { @@ -16,33 +16,37 @@ QUnit.module("stream", function () { var allowChunks = true; var chunkCount = 0; + var done = assert.async(); var helper = zip.generateInternalStream({streamFiles:true, type:"binarystring"}); helper .on("data", function () { chunkCount++; - equal(allowChunks, true, "be sure to get chunks only when allowed"); + assert.equal(allowChunks, true, "be sure to get chunks only when allowed"); + + /* + * We stop at ~ half of chunks. + * A setTimeout aside this stream is not reliable and can be + * triggered *after* the completion of the stream. + */ + if (chunkCount === 20) { + + allowChunks = false; + helper.pause(); + setTimeout(function () { + allowChunks = true; + helper.resume(); + }, 50); + } }) .on("error", function (e) { - start(); - ok(false, e.message); + done(); + assert.ok(false, e.message); }) .on("end", function () { - start(); + done(); }); - stop(); helper.resume(); - setTimeout(function () { - allowChunks = false; - ok(chunkCount > 0, "the stream emitted at least 1 chunk before pausing it"); - helper.pause(); - }, 10); - setTimeout(function () { - allowChunks = true; - helper.resume(); - }, 40); - - }); QUnit.module("nodejs"); diff --git a/test/index.html b/test/index.html index dfd49876..e76063aa 100644 --- a/test/index.html +++ b/test/index.html @@ -32,6 +32,8 @@ var details = log[i]; tests.push({ name: details.name, + message: details.message, + module: details.module, result: details.result, expected: details.expected, actual: details.actual,