@@ -44,7 +44,10 @@ import {
4444 longestCommonPrefix ,
4545 longestCommonSuffix ,
4646 longestUncommonInfixes ,
47+ toWords ,
48+ toTitleCase ,
4749 toKebabCase ,
50+ toSlugCase ,
4851 toSuperscript ,
4952 tverskyDistance ,
5053} from "./index.ts" ;
@@ -1225,17 +1228,67 @@ Deno.test("longestUncommonInfixes", () => {
12251228
12261229
12271230
1231+ Deno . test ( "toWords" , ( ) => {
1232+ const a = toWords ( "Malwa Plateau" ) ;
1233+ assertEquals ( a , [ "Malwa" , "Plateau" ] ) ;
1234+ const b = toWords ( "::chota::nagpur::" ) ;
1235+ assertEquals ( b , [ "chota" , "nagpur" ] ) ;
1236+ const c = toWords ( "deccan___plateau" ) ;
1237+ assertEquals ( c , [ "deccan" , "plateau" ] ) ;
1238+ const d = toWords ( "westernGhats" ) ;
1239+ assertEquals ( d , [ "western" , "Ghats" ] ) ;
1240+ const e = toWords ( "parseURLToJSON" ) ;
1241+ assertEquals ( e , [ "parse" , "URL" , "To" , "JSON" ] ) ;
1242+ } ) ;
1243+
1244+
1245+
1246+
1247+ Deno . test ( "toTitleCase" , ( ) => {
1248+ const a = toTitleCase ( "Geminid meteor shower" ) ;
1249+ assertEquals ( a , "Geminid Meteor Shower" ) ;
1250+ const b = toTitleCase ( "deccan___plateau" ) ;
1251+ assertEquals ( b , "Deccan Plateau" ) ;
1252+ const c = toTitleCase ( "parseURLToJSON" , null , "_" ) ;
1253+ assertEquals ( c , "Parse_Url_To_Json" ) ;
1254+ } ) ;
1255+
1256+
1257+
1258+
12281259Deno . test ( "toKebabCase" , ( ) => {
12291260 const a = toKebabCase ( "Malwa Plateau" ) ;
12301261 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" ) ;
1262+ const b = toKebabCase ( "malwaPlateau" ) ;
1263+ assertEquals ( b , "malwa-plateau" ) ;
1264+ const c = toKebabCase ( "::chota::nagpur::" , null , "_" ) ;
1265+ assertEquals ( c , "chota_nagpur" ) ;
1266+ const d = toKebabCase ( "deccan___plateau" , / _ + / g, "." ) ;
1267+ assertEquals ( d , "deccan.plateau" ) ;
1268+ const e = toKebabCase ( "Some text_with-mixed CASE" ) ;
1269+ assertEquals ( e , "some-text-with-mixed-case" ) ;
1270+ const f = toKebabCase ( "someTextWithMixedCase" ) ;
1271+ assertEquals ( f , "some-text-with-mixed-case" ) ;
1272+ const g = toKebabCase ( "IAmListeningToFMWhileLoadingDifferentURL" ) ;
1273+ assertEquals ( g , "i-am-listening-to-fm-while-loading-different-url" ) ;
1274+ // const h = toKebabCase("I can't believe it's not butter!");
1275+ // assertEquals(h, "i-cant-believe-its-not-butter");
1276+ } ) ;
1277+
1278+
1279+
1280+
1281+ Deno . test ( "toSlugCase" , ( ) => {
1282+ const a = toSlugCase ( "Malwa Plateau" ) ;
1283+ assertEquals ( a , "malwa-plateau" ) ;
1284+ const b = toSlugCase ( "malwaPlateau" ) ;
1285+ assertEquals ( b , "malwa-plateau" ) ;
1286+ const c = toSlugCase ( "Curaçao São Tomé & Príncipe!" ) ;
1287+ assertEquals ( c , "curacao-sao-tome-principe" ) ;
1288+ const d = toSlugCase ( "你好世界 hello world" ) ;
1289+ assertEquals ( d , "hello-world" ) ;
1290+ // const e = toSlugCase("Æther & Œuvre — résumé", null, "_");
1291+ // assertEquals(e, "aether_oeuvre_resume");
12391292} ) ;
12401293
12411294
0 commit comments