diff --git a/lib/test.js b/lib/test.js index bfd1bb14..6c91b0e2 100644 --- a/lib/test.js +++ b/lib/test.js @@ -4,6 +4,7 @@ var path = require('path'); var inherits = require('inherits'); var EventEmitter = require('events').EventEmitter; var has = require('has'); +var trim = require('string.prototype.trim'); module.exports = Test; @@ -101,7 +102,7 @@ Test.prototype.test = function (name, opts, cb) { }; Test.prototype.comment = function (msg) { - this.emit('result', msg.trim().replace(/^#\s*/, '')); + this.emit('result', trim(msg).replace(/^#\s*/, '')); }; Test.prototype.plan = function (n) { diff --git a/package.json b/package.json index ddc48d46..cd703a96 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,7 @@ "inherits": "~2.0.1", "object-inspect": "~1.0.0", "resumer": "~0.0.0", + "string.prototype.trim": "^1.1.1", "through": "~2.3.4" }, "devDependencies": { diff --git a/test/array.js b/test/array.js index 2d498632..fbbff16e 100644 --- a/test/array.js +++ b/test/array.js @@ -1,6 +1,7 @@ var falafel = require('falafel'); var tape = require('../'); var tap = require('tap'); +var trim = require('string.prototype.trim'); tap.test('array test', function (tt) { tt.plan(1); @@ -13,7 +14,7 @@ tap.test('array test', function (tt) { tc.on('end', function () { var rs = rows.map(function (r) { if (r && typeof r === 'object') { - return { id : r.id, ok : r.ok, name : r.name.trim() }; + return { id : r.id, ok : r.ok, name : trim(r.name) }; } else return r; }); diff --git a/test/end-as-callback.js b/test/end-as-callback.js index 678ddf68..df0bcbc3 100644 --- a/test/end-as-callback.js +++ b/test/end-as-callback.js @@ -1,5 +1,6 @@ var tap = require("tap"); var tape = require("../"); +var trim = require('string.prototype.trim'); tap.test("tape assert.end as callback", function (tt) { var test = tape.createHarness({ exit: false }) @@ -10,7 +11,7 @@ tap.test("tape assert.end as callback", function (tt) { tc.on("end", function () { var rs = rows.map(function (r) { return r && typeof r === "object" ? - { id: r.id, ok: r.ok, name: r.name.trim() } : + { id: r.id, ok: r.ok, name: trim(r.name) } : r }) diff --git a/test/exit.js b/test/exit.js index 8055e5e6..02d2488b 100644 --- a/test/exit.js +++ b/test/exit.js @@ -1,5 +1,6 @@ var tap = require('tap'); var spawn = require('child_process').spawn; +var trim = require('string.prototype.trim'); tap.test('exit ok', function (t) { t.plan(2); @@ -11,7 +12,7 @@ tap.test('exit ok', function (t) { tc.on('end', function () { var rs = rows.map(function (r) { if (r && typeof r === 'object') { - return { id : r.id, ok : r.ok, name : r.name.trim() }; + return { id : r.id, ok : r.ok, name : trim(r.name) }; } else return r; }); @@ -47,7 +48,7 @@ tap.test('exit fail', function (t) { tc.on('end', function () { var rs = rows.map(function (r) { if (r && typeof r === 'object') { - return { id : r.id, ok : r.ok, name : r.name.trim() }; + return { id : r.id, ok : r.ok, name : trim(r.name) }; } else return r; }); @@ -82,7 +83,7 @@ tap.test('too few exit', function (t) { tc.on('end', function () { var rs = rows.map(function (r) { if (r && typeof r === 'object') { - return { id : r.id, ok : r.ok, name : r.name.trim() }; + return { id : r.id, ok : r.ok, name : trim(r.name) }; } else return r; }); @@ -118,7 +119,7 @@ tap.test('more planned in a second test', function (t) { tc.on('end', function () { var rs = rows.map(function (r) { if (r && typeof r === 'object') { - return { id : r.id, ok : r.ok, name : r.name.trim() }; + return { id : r.id, ok : r.ok, name : trim(r.name) }; } else return r; }); diff --git a/test/fail.js b/test/fail.js index d56045ad..c39666ae 100644 --- a/test/fail.js +++ b/test/fail.js @@ -1,6 +1,7 @@ var falafel = require('falafel'); var tape = require('../'); var tap = require('tap'); +var trim = require('string.prototype.trim'); tap.test('array test', function (tt) { tt.plan(1); @@ -13,7 +14,7 @@ tap.test('array test', function (tt) { tc.on('end', function () { var rs = rows.map(function (r) { if (r && typeof r === 'object') { - return { id : r.id, ok : r.ok, name : r.name.trim() }; + return { id : r.id, ok : r.ok, name : trim(r.name) }; } else return r; }); diff --git a/test/nested-sync-noplan-noend.js b/test/nested-sync-noplan-noend.js index a206c501..874f27b1 100644 --- a/test/nested-sync-noplan-noend.js +++ b/test/nested-sync-noplan-noend.js @@ -1,5 +1,6 @@ var tape = require('../'); var tap = require('tap'); +var trim = require('string.prototype.trim'); tap.test('nested sync test without plan or end', function (tt) { tt.plan(1); @@ -12,7 +13,7 @@ tap.test('nested sync test without plan or end', function (tt) { tc.on('end', function () { var rs = rows.map(function (r) { if (r && typeof r === 'object') { - return { id : r.id, ok : r.ok, name : r.name.trim() }; + return { id : r.id, ok : r.ok, name : trim(r.name) }; } else return r; }); diff --git a/test/nested.js b/test/nested.js index 673465d4..3b376385 100644 --- a/test/nested.js +++ b/test/nested.js @@ -1,6 +1,7 @@ var falafel = require('falafel'); var tape = require('../'); var tap = require('tap'); +var trim = require('string.prototype.trim'); tap.test('array test', function (tt) { tt.plan(1); @@ -13,7 +14,7 @@ tap.test('array test', function (tt) { tc.on('end', function () { var rs = rows.map(function (r) { if (r && typeof r === 'object') { - return { id : r.id, ok : r.ok, name : r.name.trim() }; + return { id : r.id, ok : r.ok, name : trim(r.name) }; } else return r; }); diff --git a/test/only.js b/test/only.js index 9e6bc26f..2decdc9c 100644 --- a/test/only.js +++ b/test/only.js @@ -1,5 +1,6 @@ var tap = require('tap'); var tape = require('../'); +var trim = require('string.prototype.trim'); tap.test('tape only test', function (tt) { var test = tape.createHarness({ exit: false }); @@ -11,7 +12,7 @@ tap.test('tape only test', function (tt) { tc.on('end', function () { var rs = rows.map(function (r) { if (r && typeof r === 'object') { - return { id: r.id, ok: r.ok, name: r.name.trim() }; + return { id: r.id, ok: r.ok, name: trim(r.name) }; } else { return r; diff --git a/test/timeoutAfter.js b/test/timeoutAfter.js index bd2a4f1b..48b1c0f1 100644 --- a/test/timeoutAfter.js +++ b/test/timeoutAfter.js @@ -1,5 +1,6 @@ var tape = require('../'); var tap = require('tap'); +var trim = require('string.prototype.trim'); tap.test('timeoutAfter test', function (tt) { tt.plan(1); @@ -12,7 +13,7 @@ tap.test('timeoutAfter test', function (tt) { tc.on('end', function () { var rs = rows.map(function (r) { if (r && typeof r === 'object') { - return { id : r.id, ok : r.ok, name : r.name.trim() }; + return { id : r.id, ok : r.ok, name : trim(r.name) }; } else return r; }); diff --git a/test/too_many.js b/test/too_many.js index b5c38819..56c2225a 100644 --- a/test/too_many.js +++ b/test/too_many.js @@ -1,6 +1,7 @@ var falafel = require('falafel'); var tape = require('../'); var tap = require('tap'); +var trim = require('string.prototype.trim'); tap.test('array test', function (tt) { tt.plan(1); @@ -13,7 +14,7 @@ tap.test('array test', function (tt) { tc.on('end', function () { var rs = rows.map(function (r) { if (r && typeof r === 'object') { - return { id : r.id, ok : r.ok, name : r.name.trim() }; + return { id : r.id, ok : r.ok, name : trim(r.name) }; } else return r; });