Upstream EvanHahn/HumanizeDuration.js state of the touched files before 13ba5bab06
This commit is contained in:
1 parent
117fd38eeb
commit
194562d9da
2 files changed
+1
-16
No files matched your search
@@ -1382,9 +1382,7 @@
|
|||||||
var languageWord = language[unitName];
|
var languageWord = language[unitName];
|
||||||
var word;
|
var word;
|
||||||
if (typeof languageWord === "function") {
|
if (typeof languageWord === "function") {
|
||||||
// Pluralize on the rendered count: `maxDecimalPoints` may truncate 1.5 to
|
word = languageWord(unitCount);
|
||||||
// "1", and the word must agree with what is shown.
|
|
||||||
word = languageWord(normalizedUnitCount);
|
|
||||||
} else {
|
} else {
|
||||||
word = languageWord;
|
word = languageWord;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -162,19 +162,6 @@ describe("humanizer", function () {
|
|||||||
assert.strictEqual(h(7999), "7.999 seconds");
|
assert.strictEqual(h(7999), "7.999 seconds");
|
||||||
});
|
});
|
||||||
|
|
||||||
it('pluralizes based on the count rendered by "maxDecimalPoints"', function () {
|
|
||||||
// A count truncated to exactly 1 must take the singular word.
|
|
||||||
assert.strictEqual(humanizer({ maxDecimalPoints: 0 })(1500), "1 second");
|
|
||||||
assert.strictEqual(humanizer({ maxDecimalPoints: 2 })(1005), "1 second");
|
|
||||||
// A truncated count that is not 1 stays plural.
|
|
||||||
assert.strictEqual(humanizer({ maxDecimalPoints: 0 })(2500), "2 seconds");
|
|
||||||
// German shares the same singular/plural mechanism.
|
|
||||||
assert.strictEqual(
|
|
||||||
humanizer({ language: "de", maxDecimalPoints: 0 })(1500),
|
|
||||||
"1 Sekunde"
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("can ask for the largest units", function () {
|
it("can ask for the largest units", function () {
|
||||||
const h = humanizer({ largest: 2 });
|
const h = humanizer({ largest: 2 });
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user