fix(helpers): keep fullform singular for negative one-magnitude values
decorateResult() captured numericValue (used to pick the singular vs
plural fullform suffix) after the negative sign was already prefixed
onto result[0], so filesize(-1, {fullform: true}) compared -1 === 1
and wrongly pluralized to "-1 bytes" instead of "-1 byte". Capture the
magnitude before the sign is applied instead.
This commit is contained in:
1 parent
3da8421ddf
commit
7b781162ac
2 files changed
+22
-10
No files matched your search
@@ -268,6 +268,16 @@ describe("filesize", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("should keep the singular fullform name for negative one-magnitude values", () => {
|
||||
assert.strictEqual(filesize(-1, { fullform: true }), "-1 byte");
|
||||
assert.strictEqual(filesize(-0.125, { bits: true, fullform: true }), "-1 bit");
|
||||
});
|
||||
|
||||
it("should keep the plural fullform name for negative values", () => {
|
||||
assert.strictEqual(filesize(-2, { fullform: true }), "-2 bytes");
|
||||
assert.strictEqual(filesize(-0.25, { bits: true, fullform: true }), "-2 bits");
|
||||
});
|
||||
|
||||
it("should handle bits fullform singular", () => {
|
||||
assert.strictEqual(filesize(0.125, { bits: true, fullform: true }), "1 bit");
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user