11import { describe , it , expect } from "vitest" ;
22import { replaceAccents } from "../../src/ts/test/lazy-mode" ;
33
4- let germanAccents = [
5- [ "ö" , "oe" ] ,
6- [ "ä" , "ae" ] ,
7- [ "ü" , "ue" ] ,
8- ] as [ string , string ] [ ] ;
9-
10- let multicharAccents = [
11- [ "a" , "bc" ] ,
12- [ "de" , "f" ] ,
13- [ "gh" , "ij" ] ,
4+ let additionalAccents = [
5+ [ "abc" , "1" ] ,
6+ [ "def" , "22" ] ,
7+ [ "gh" , "333" ] ,
148] as [ string , string ] [ ] ;
159
1610describe ( "lazy-mode" , ( ) => {
@@ -31,36 +25,17 @@ describe("lazy-mode", () => {
3125 const result = replaceAccents ( "" ) ;
3226 expect ( result ) . toBe ( "" ) ;
3327 } ) ;
34- describe ( "german accents" , ( ) => {
35- it ( "should replace additional accents" , ( ) => {
36- const result = replaceAccents ( "Tränenüberströmt" , germanAccents ) ;
37- expect ( result ) . toBe ( "Traenenueberstroemt" ) ;
38- } ) ;
39- it ( "should replace starting with uppercase accent" , ( ) => {
40- const result = replaceAccents ( "Äpfel" , germanAccents ) ;
41- expect ( result ) . toBe ( "Aepfel" ) ;
42- } ) ;
43- it ( "should replace common accents" , ( ) => {
44- const result = replaceAccents ( "äße" , germanAccents ) ;
45- expect ( result ) . toBe ( "aesse" ) ;
46- } ) ;
47- } ) ;
48- describe ( "multicharacter accents" , ( ) => {
49- it ( "should correctly replace multicharacter accents" , ( ) => {
50- const tests = [
51- { input : "a" , expected : "bc" } ,
52- { input : "aa" , expected : "bcbc" } ,
53- { input : "de" , expected : "f" } ,
54- { input : "dede" , expected : "ff" } ,
55- { input : "gh" , expected : "ij" } ,
56- { input : "ghgh" , expected : "ijij" } ,
57- { input : "abcdefgh" , expected : "bcbcffij" } ,
58- ] ;
59-
60- tests . forEach ( ( { input, expected } ) => {
61- const result = replaceAccents ( input , multicharAccents ) ;
62- expect ( result ) . toBe ( expected ) ;
63- } ) ;
28+ it ( "should correctly use additional accents" , ( ) => {
29+ const tests = [
30+ { input : "abc" , expected : "111" } ,
31+ { input : "abcdef" , expected : "111222222" } ,
32+ { input : "gh" , expected : "333333" } ,
33+ { input : "abcdefgh" , expected : "111222222333333" } ,
34+ { input : "zzdzz" , expected : "zz22zz" } ,
35+ ] ;
36+ tests . forEach ( ( { input, expected } ) => {
37+ const result = replaceAccents ( input , additionalAccents ) ;
38+ expect ( result ) . toBe ( expected ) ;
6439 } ) ;
6540 } ) ;
6641 } ) ;
0 commit comments