-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
117 additions
and
4 deletions.
There are no files selected for viewing
38 changes: 36 additions & 2 deletions
38
test/source/constants/transformers/pluralisers/common-european.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,39 @@ | ||
import { describe } from "bun:test"; | ||
import { describe, it } from "bun:test"; | ||
import pluralise from "logos:constants/transformers/pluralisers/common-european"; | ||
import { expect } from "chai"; | ||
|
||
describe("pluralise()", () => { | ||
// TODO(vxern): Test. | ||
const FORMS = { one: "thing", two: "things" }; | ||
|
||
it("returns undefined when the passed object does not contain forms `one` and `two`.", () => { | ||
expect(pluralise("0", {})).to.be.undefined; | ||
expect(pluralise("1", { one: "thing" })).to.be.undefined; | ||
expect(pluralise("2", { two: "things" })).to.be.undefined; | ||
}); | ||
|
||
it("does not return undefined when the passed object contains forms `one` and `two`.", () => { | ||
expect(pluralise("2", FORMS)).to.not.be.undefined; | ||
}); | ||
|
||
it("returns the singular form when the quantity is 1.", () => { | ||
expect(pluralise("1", FORMS)).to.equal("thing"); | ||
}); | ||
|
||
it("returns the plural form when the quantity is 0.", () => { | ||
expect(pluralise("0", FORMS)).to.equal("things"); | ||
}); | ||
|
||
it("returns the singular form when the quantity is -1.", () => { | ||
expect(pluralise("1", FORMS)).to.equal("thing"); | ||
}); | ||
|
||
it("returns the plural form for numbers 2 or more.", () => { | ||
expect(pluralise("2", FORMS)).to.equal("things"); | ||
expect(pluralise("3", FORMS)).to.equal("things"); | ||
}); | ||
|
||
it("returns the plural form for numbers -2 or less.", () => { | ||
expect(pluralise("-2", FORMS)).to.equal("things"); | ||
expect(pluralise("-3", FORMS)).to.equal("things"); | ||
}); | ||
}); |
83 changes: 81 additions & 2 deletions
83
test/source/constants/transformers/pluralisers/common-slavic.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,84 @@ | ||
import { describe } from "bun:test"; | ||
import { describe, it } from "bun:test"; | ||
import pluralise from "logos:constants/transformers/pluralisers/common-slavic.ts"; | ||
import { expect } from "chai"; | ||
|
||
describe("pluralise()", () => { | ||
// TODO(vxern): Test. | ||
const FORMS = { one: "dom", two: "domy", many: "domów" }; | ||
|
||
it("returns undefined if the passed object does not contain forms `one`, `two` and `many`.", () => { | ||
expect(pluralise("0", {})).to.be.undefined; | ||
expect(pluralise("1", { one: "dom" })).to.be.undefined; | ||
expect(pluralise("2", { one: "dom", two: "domy" })).to.be.undefined; | ||
expect(pluralise("2", { two: "domy" })).to.be.undefined; | ||
expect(pluralise("5", { two: "domy", many: "domów" })).to.be.undefined; | ||
expect(pluralise("5", { many: "domów" })).to.be.undefined; | ||
}); | ||
|
||
it("does not return undefined when the passed object contains forms `one`, `two` and `many`.", () => { | ||
expect(pluralise("5", FORMS)).to.not.be.undefined; | ||
}); | ||
|
||
it("returns the singular form when the quantity is 1.", () => { | ||
expect(pluralise("1", FORMS)).to.equal("dom"); | ||
}); | ||
|
||
it("returns the genitive plural form when the quantity is 0.", () => { | ||
expect(pluralise("0", FORMS)).to.equal("domów"); | ||
}); | ||
|
||
it("returns the singular form when the quantity is -1.", () => { | ||
expect(pluralise("1", FORMS)).to.equal("dom"); | ||
}); | ||
|
||
it("returns the nominative plural form when the quantity is 2, 3 or 4.", () => { | ||
expect(pluralise("2", FORMS)).to.equal("domy"); | ||
expect(pluralise("3", FORMS)).to.equal("domy"); | ||
expect(pluralise("4", FORMS)).to.equal("domy"); | ||
}); | ||
|
||
it("returns the nominative plural form when the quantity is -2, -3 or -4.", () => { | ||
expect(pluralise("-2", FORMS)).to.equal("domy"); | ||
expect(pluralise("-3", FORMS)).to.equal("domy"); | ||
expect(pluralise("-4", FORMS)).to.equal("domy"); | ||
}); | ||
|
||
it("returns the genitive plural form when the quantity is 5 or more.", () => { | ||
expect(pluralise("5", FORMS)).to.equal("domów"); | ||
expect(pluralise("6", FORMS)).to.equal("domów"); | ||
}); | ||
|
||
it("returns the genitive plural form when the quantity is -5 or less.", () => { | ||
expect(pluralise("-5", FORMS)).to.equal("domów"); | ||
expect(pluralise("-6", FORMS)).to.equal("domów"); | ||
}); | ||
|
||
it("returns the genitive plural form when the quantity is 12, 13 or 14.", () => { | ||
expect(pluralise("12", FORMS)).to.equal("domów"); | ||
expect(pluralise("13", FORMS)).to.equal("domów"); | ||
expect(pluralise("14", FORMS)).to.equal("domów"); | ||
}); | ||
|
||
it("returns the genitive plural form when the quantity is -12, -13 or -14.", () => { | ||
expect(pluralise("-12", FORMS)).to.equal("domów"); | ||
expect(pluralise("-13", FORMS)).to.equal("domów"); | ||
expect(pluralise("-14", FORMS)).to.equal("domów"); | ||
}); | ||
|
||
it("returns the nominative plural form when the quantity ends in 2, 3 or 4 for numbers larger than 14.", () => { | ||
expect(pluralise("22", FORMS)).to.equal("domy"); | ||
expect(pluralise("23", FORMS)).to.equal("domy"); | ||
expect(pluralise("24", FORMS)).to.equal("domy"); | ||
expect(pluralise("32", FORMS)).to.equal("domy"); | ||
expect(pluralise("33", FORMS)).to.equal("domy"); | ||
expect(pluralise("34", FORMS)).to.equal("domy"); | ||
}); | ||
|
||
it("returns the nominative plural form when the quantity ends in 2, 3 or 4 for numbers smaller than -14.", () => { | ||
expect(pluralise("-22", FORMS)).to.equal("domy"); | ||
expect(pluralise("-23", FORMS)).to.equal("domy"); | ||
expect(pluralise("-24", FORMS)).to.equal("domy"); | ||
expect(pluralise("-32", FORMS)).to.equal("domy"); | ||
expect(pluralise("-33", FORMS)).to.equal("domy"); | ||
expect(pluralise("-34", FORMS)).to.equal("domy"); | ||
}); | ||
}); |