fix bug in humanSizeFromBytes

This commit is contained in:
Dave Eddy 2015-09-01 13:44:10 -04:00
parent c4f85db8d8
commit 42f0ee5a41
2 changed files with 11 additions and 1 deletions

View File

@ -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.

View File

@ -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();
});