Skip to content

Commit

Permalink
fix: use 'toReadable' in 'pluralize' helper
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelmaeuer committed Apr 19, 2023
1 parent 4ce19c9 commit 0eb7e9a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
8 changes: 4 additions & 4 deletions tests/strings.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,16 +152,16 @@ describe('Test Strings Package', () => {
expect(strings.pluralize(1, 'Apple')).to.equal('1 Apple')
})

it("pluralize(2, 'Apple') = '2 Apples'", () => {
expect(strings.pluralize(2, 'Apple')).to.equal('2 Apples')
it("pluralize(1000, 'Apple') = '1.000 Apples'", () => {
expect(strings.pluralize(1000, 'Apple')).to.equal('1.000 Apples')
})

it("pluralize(1, 'Child', 'Children') = '1 Child'", () => {
expect(strings.pluralize(1, 'Child', 'Children')).to.equal('1 Child')
})

it("pluralize(2, 'Child', 'Children') = '2 Children'", () => {
expect(strings.pluralize(2, 'Child', 'Children')).to.equal('2 Children')
it("pluralize(1000, 'Child', 'Children') = '1.000 Children'", () => {
expect(strings.pluralize(1000, 'Child', 'Children')).to.equal('1.000 Children')
})
})

Expand Down
4 changes: 3 additions & 1 deletion utils/strings/pluralize.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
const toReadable = require('../numbers/toReadable')

// pluralize value to values or use custom plural
module.exports = (count, singular, plural) => {
const multi = plural ?? `${singular}s`
return `${count} ${count !== 1 ? multi : singular}`
return `${toReadable(count)} ${count !== 1 ? multi : singular}`
}

0 comments on commit 0eb7e9a

Please sign in to comment.