diff --git a/lib/common.js b/lib/common.js index 2a5eaaa..b7a6750 100755 --- a/lib/common.js +++ b/lib/common.js @@ -192,8 +192,8 @@ function humanDurationFromMs(ms) { */ function humanSizeFromBytes(opts, bytes) { if (bytes === undefined) { - opts = {}; bytes = opts; + opts = {}; } assert.number(bytes, 'bytes'); // The number of decimal places, default 1. diff --git a/test/unit/common.test.js b/test/unit/common.test.js index de25107..096c377 100644 --- a/test/unit/common.test.js +++ b/test/unit/common.test.js @@ -35,6 +35,16 @@ test('humanDurationFromMs', function (t) { t.equal(humanDurationFromMs(47*second), '47s'); t.equal(humanDurationFromMs(1*week), '1w'); + t.equal(humanDurationFromMs(0), '0ms'); + + t.end(); +}); + +test('humanSizeFromBytes', function (t) { + var humanSizeFromBytes = common.humanSizeFromBytes; + + t.equal(humanSizeFromBytes(0), '0 B'); + t.equal(humanSizeFromBytes({}, 0), '0 B'); t.end(); });