11import { describe , expect , it } from "vitest" ;
2- import { kebabToCamelCase } from "../src/strings" ;
2+ import { kebabToCamelCase , sanitizeString } from "../src/strings" ;
33
44describe ( "strings" , ( ) => {
55 describe ( "kebabToCamelCase" , ( ) => {
@@ -11,4 +11,56 @@ describe("strings", () => {
1111 ) . toEqual ( "oneTwoThreeFourFiveSixSevenEightNineTen" ) ;
1212 } ) ;
1313 } ) ;
14+
15+ describe ( "sanitizeString" , ( ) => {
16+ const testCases = [
17+ {
18+ input : "h̶̼͔̭͈̏́̀́͋͜ͅe̵̺̞̦̫̫͔̋́̅̅̃̀͝͝ļ̶̬̯͚͇̺͍̞̫̟͖͋̓͛̆̒̓͜ĺ̴̗̘͇̬̆͂͌̈͊͝͝ỡ̴̡̦̩̠̞̐̃͆̚͠͝" ,
19+ expected : "hello" ,
20+ } ,
21+ {
22+ input : "hello" ,
23+ expected : "hello" ,
24+ } ,
25+ {
26+ input : "hel lo" ,
27+ expected : "hel lo" ,
28+ } ,
29+ {
30+ input : " hel lo " ,
31+ expected : "hel lo" ,
32+ } ,
33+ {
34+ input : "" ,
35+ expected : "" ,
36+ } ,
37+ {
38+ input : " \n\n\n" ,
39+ expected : "" ,
40+ } ,
41+ {
42+ input : undefined ,
43+ expected : undefined ,
44+ } ,
45+ {
46+ input : "hello\r\n\r\nworld" ,
47+ expected : "hello\r\n\r\nworld" ,
48+ } ,
49+ {
50+ input : "hello\n\nworld" ,
51+ expected : "hello\n\nworld" ,
52+ } ,
53+ {
54+ input : "test \r\n test" ,
55+ expected : "test \r\n test" ,
56+ } ,
57+ ] ;
58+
59+ it . each ( testCases ) (
60+ "sanitizeString with input '$input' expects '$expected'" ,
61+ ( { input, expected } ) => {
62+ expect ( sanitizeString ( input ) ) . toEqual ( expected ) ;
63+ } ,
64+ ) ;
65+ } ) ;
1466} ) ;
0 commit comments