@@ -44,7 +44,9 @@ import {
4444 longestCommonPrefix ,
4545 longestCommonSuffix ,
4646 longestUncommonInfixes ,
47+ toWords ,
4748 toKebabCase ,
49+ toSlugCase ,
4850 toSuperscript ,
4951 tverskyDistance ,
5052} from "./index.ts" ;
@@ -1225,17 +1227,55 @@ Deno.test("longestUncommonInfixes", () => {
12251227
12261228
12271229
1230+ Deno . test ( "toWords" , ( ) => {
1231+ const a = toWords ( "Malwa Plateau" ) ;
1232+ assertEquals ( a , [ "Malwa" , "Plateau" ] ) ;
1233+ const b = toWords ( "::chota::nagpur::" ) ;
1234+ assertEquals ( b , [ "chota" , "nagpur" ] ) ;
1235+ const c = toWords ( "deccan___plateau" ) ;
1236+ assertEquals ( c , [ "deccan" , "plateau" ] ) ;
1237+ const d = toWords ( "westernGhats" ) ;
1238+ assertEquals ( d , [ "western" , "Ghats" ] ) ;
1239+ const e = toWords ( "parseURLToJSON" ) ;
1240+ assertEquals ( e , [ "parse" , "URL" , "To" , "JSON" ] ) ;
1241+ } ) ;
1242+
1243+
1244+
1245+
12281246Deno . test ( "toKebabCase" , ( ) => {
12291247 const a = toKebabCase ( "Malwa Plateau" ) ;
12301248 assertEquals ( a , "malwa-plateau" ) ;
1231- const b = toKebabCase ( "::chota::nagpur::" , null , "_" ) ;
1232- assertEquals ( b , "chota_nagpur" ) ;
1233- const c = toKebabCase ( "deccan___plateau" , / _ + / g, "." ) ;
1234- assertEquals ( c , "deccan.plateau" ) ;
1235- const d = toKebabCase ( "Some text_with-mixed CASE" ) ;
1236- assertEquals ( d , "some-text-with-mixed-case" ) ;
1237- const e = toKebabCase ( "IAmListeningToFMWhileLoadingDifferentURL" ) ;
1238- assertEquals ( e , "i-am-listening-to-fm-while-loading-different-url" ) ;
1249+ const b = toKebabCase ( "malwaPlateau" ) ;
1250+ assertEquals ( b , "malwa-plateau" ) ;
1251+ const c = toKebabCase ( "::chota::nagpur::" , null , "_" ) ;
1252+ assertEquals ( c , "chota_nagpur" ) ;
1253+ const d = toKebabCase ( "deccan___plateau" , / _ + / g, "." ) ;
1254+ assertEquals ( d , "deccan.plateau" ) ;
1255+ const e = toKebabCase ( "Some text_with-mixed CASE" ) ;
1256+ assertEquals ( e , "some-text-with-mixed-case" ) ;
1257+ const f = toKebabCase ( "someTextWithMixedCase" ) ;
1258+ assertEquals ( f , "some-text-with-mixed-case" ) ;
1259+ const g = toKebabCase ( "IAmListeningToFMWhileLoadingDifferentURL" ) ;
1260+ assertEquals ( g , "i-am-listening-to-fm-while-loading-different-url" ) ;
1261+ // const h = toKebabCase("I can't believe it's not butter!");
1262+ // assertEquals(h, "i-cant-believe-its-not-butter");
1263+ } ) ;
1264+
1265+
1266+
1267+
1268+ Deno . test ( "toSlugCase" , ( ) => {
1269+ const a = toSlugCase ( "Malwa Plateau" ) ;
1270+ assertEquals ( a , "malwa-plateau" ) ;
1271+ const b = toSlugCase ( "malwaPlateau" ) ;
1272+ assertEquals ( b , "malwa-plateau" ) ;
1273+ const c = toSlugCase ( "Curaçao São Tomé & Príncipe!" ) ;
1274+ assertEquals ( c , "curacao-sao-tome-principe" ) ;
1275+ const d = toSlugCase ( "你好世界 hello world" ) ;
1276+ assertEquals ( d , "hello-world" ) ;
1277+ // const e = toSlugCase("Æther & Œuvre — résumé", null, "_");
1278+ // assertEquals(e, "aether_oeuvre_resume");
12391279} ) ;
12401280
12411281
0 commit comments