| 1 |
"use strict"; |
| 2 |
|
| 3 |
var startsWith = require("es5-ext/string/#/starts-with") |
| 4 |
, spawn = require("child_process").spawn |
| 5 |
, resolve = require("path").resolve; |
| 6 |
|
| 7 |
var pg = resolve(__dirname, "__playground"); |
| 8 |
|
| 9 |
module.exports = { |
| 10 |
"": function (a, d) { |
| 11 |
var t = spawn("node", [resolve(pg, "throbber.js")]), out = [], err = ""; |
| 12 |
|
| 13 |
t.stdout.on("data", function (data) { out.push(data); }); |
| 14 |
t.stderr.on("data", function (data) { err += data; }); |
| 15 |
t.on("exit", function () { |
| 16 |
a.ok(out.length > 4, "Interval"); |
| 17 |
a(startsWith.call(out.join(""), "START-\b\\\b|\b/\b-\b"), true, "Output"); |
| 18 |
a(err, "", "No stderr output"); |
| 19 |
d(); |
| 20 |
}); |
| 21 |
}, |
| 22 |
"Formatted": function (a, d) { |
| 23 |
var t = spawn("node", [resolve(pg, "throbber.formatted.js")]), out = [], err = ""; |
| 24 |
|
| 25 |
t.stdout.on("data", function (data) { out.push(data); }); |
| 26 |
t.stderr.on("data", function (data) { err += data; }); |
| 27 |
t.on("exit", function () { |
| 28 |
a.ok(out.length > 4, "Interval"); |
| 29 |
var isNoColor = Boolean(process.env.NO_COLOR); |
| 30 |
if (isNoColor) { |
| 31 |
a(startsWith.call(out.join(""), "START"), true, "Output"); |
| 32 |
} else { |
| 33 |
a( |
| 34 |
startsWith.call( |
| 35 |
out.join(""), |
| 36 |
"START\x1b[31m-\x1b[39m\x1b[31m\b\\\x1b" + |
| 37 |
"[39m\x1b[31m\b|\x1b[39m\x1b[31m\b/\x1b[39m\x1b[31m\b-\x1b[39m" |
| 38 |
), |
| 39 |
true, "Output" |
| 40 |
); |
| 41 |
} |
| 42 |
a(err, "", "No stderr output"); |
| 43 |
d(); |
| 44 |
}); |
| 45 |
} |
| 46 |
}; |