|
| 1 | +import { replace as replace } from "../../src/ts/test/british-english"; |
| 2 | +import Config from "../../src/ts/config"; |
| 3 | + |
| 4 | +describe("british-english", () => { |
| 5 | + describe("replace", () => { |
| 6 | + beforeEach(() => (Config.mode = "time")); |
| 7 | + |
| 8 | + it("should not replace words with no rule", () => { |
| 9 | + expect(replace("test", "")).resolves.toEqual("test"); |
| 10 | + expect(replace("Test", "")).resolves.toEqual("Test"); |
| 11 | + }); |
| 12 | + |
| 13 | + it("should replace words", () => { |
| 14 | + expect(replace("math", "")).resolves.toEqual("maths"); |
| 15 | + expect(replace("Math", "")).resolves.toEqual("Maths"); |
| 16 | + }); |
| 17 | + |
| 18 | + it("should replace words with non-word characters around", () => { |
| 19 | + expect(replace(" :math-. ", "")).resolves.toEqual(" :maths-. "); |
| 20 | + expect(replace(" :Math-. ", "")).resolves.toEqual(" :Maths-. "); |
| 21 | + }); |
| 22 | + |
| 23 | + it("should not replace in quote mode if previousWord matches excepted words", () => { |
| 24 | + //GIVEN |
| 25 | + Config.mode = "quote"; |
| 26 | + |
| 27 | + //WHEN/THEN |
| 28 | + expect(replace("tire", "will")).resolves.toEqual("tire"); |
| 29 | + expect(replace("tire", "")).resolves.toEqual("tyre"); |
| 30 | + }); |
| 31 | + |
| 32 | + it("should replace hyphenated words", () => { |
| 33 | + expect(replace("cream-colored", "")).resolves.toEqual("cream-coloured"); |
| 34 | + expect(replace("armor-flavoring", "")).resolves.toEqual( |
| 35 | + "armour-flavouring" |
| 36 | + ); |
| 37 | + }); |
| 38 | + }); |
| 39 | +}); |
0 commit comments