@@ -208,4 +208,154 @@ describe('helpers', () => {
208208 expect ( object . hasBeenLogged ) . toEqual ( buildError . hasBeenLogged ) ;
209209 } ) ;
210210 } ) ;
211+
212+ describe ( 'upperCaseFirst' , ( ) => {
213+ it ( 'should capitalize a one character string' , ( ) => {
214+ const result = helpers . upperCaseFirst ( 't' ) ;
215+ expect ( result ) . toEqual ( 'T' ) ;
216+ } ) ;
217+
218+ it ( 'should capitalize the first character of string' , ( ) => {
219+ const result = helpers . upperCaseFirst ( 'taco' ) ;
220+ expect ( result ) . toEqual ( 'Taco' ) ;
221+ } ) ;
222+ } ) ;
223+
224+ describe ( 'removeCaseFromString' , ( ) => {
225+ const map = new Map < string , string > ( ) ;
226+ map . set ( 'test' , 'test' ) ;
227+ map . set ( 'TEST' , 'test' ) ;
228+ map . set ( 'testString' , 'test string' ) ;
229+ map . set ( 'testString123' , 'test string123' ) ;
230+ map . set ( 'testString_1_2_3' , 'test string 1 2 3' ) ;
231+ map . set ( 'x_256' , 'x 256' ) ;
232+ map . set ( 'anHTMLTag' , 'an html tag' ) ;
233+ map . set ( 'ID123String' , 'id123 string' ) ;
234+ map . set ( 'Id123String' , 'id123 string' ) ;
235+ map . set ( 'foo bar123' , 'foo bar123' ) ;
236+ map . set ( 'a1bStar' , 'a1b star' ) ;
237+ map . set ( 'CONSTANT_CASE' , 'constant case' ) ;
238+ map . set ( 'CONST123_FOO' , 'const123 foo' ) ;
239+ map . set ( 'FOO_bar' , 'foo bar' ) ;
240+ map . set ( 'dot.case' , 'dot case' ) ;
241+ map . set ( 'path/case' , 'path case' ) ;
242+ map . set ( 'snake_case' , 'snake case' ) ;
243+ map . set ( 'snake_case123' , 'snake case123' ) ;
244+ map . set ( 'snake_case_123' , 'snake case 123' ) ;
245+ map . set ( '"quotes"' , 'quotes' ) ;
246+ map . set ( 'version 0.45.0' , 'version 0 45 0' ) ;
247+ map . set ( 'version 0..78..9' , 'version 0 78 9' ) ;
248+ map . set ( 'version 4_99/4' , 'version 4 99 4' ) ;
249+ map . set ( 'amazon s3 data' , 'amazon s3 data' ) ;
250+ map . set ( 'foo_13_bar' , 'foo 13 bar' ) ;
251+
252+ map . forEach ( ( value : string , key : string ) => {
253+ const result = helpers . removeCaseFromString ( key ) ;
254+ expect ( result ) . toEqual ( value ) ;
255+ } ) ;
256+ } ) ;
257+
258+ describe ( 'sentenceCase' , ( ) => {
259+ it ( 'should lower case a single word' , ( ) => {
260+ const resultOne = helpers . sentenceCase ( 'test' ) ;
261+ const resultTwo = helpers . sentenceCase ( 'TEST' ) ;
262+ expect ( resultOne ) . toEqual ( 'Test' ) ;
263+ expect ( resultTwo ) . toEqual ( 'Test' ) ;
264+ } ) ;
265+
266+ it ( 'should sentence case regular sentence cased strings' , ( ) => {
267+ const resultOne = helpers . sentenceCase ( 'test string' ) ;
268+ const resultTwo = helpers . sentenceCase ( 'Test String' ) ;
269+
270+ expect ( resultOne ) . toEqual ( 'Test string' ) ;
271+ expect ( resultTwo ) . toEqual ( 'Test string' ) ;
272+ } ) ;
273+
274+ it ( 'should sentence case non-alphanumeric separators' , ( ) => {
275+ const resultOne = helpers . sentenceCase ( 'dot.case' ) ;
276+ const resultTwo = helpers . sentenceCase ( 'path/case' ) ;
277+ expect ( resultOne ) . toEqual ( 'Dot case' ) ;
278+ expect ( resultTwo ) . toEqual ( 'Path case' ) ;
279+ } ) ;
280+ } ) ;
281+
282+ describe ( 'camelCase' , ( ) => {
283+ it ( 'should lower case a single word' , ( ) => {
284+ const resultOne = helpers . camelCase ( 'test' ) ;
285+ const resultTwo = helpers . camelCase ( 'TEST' ) ;
286+ expect ( resultOne ) . toEqual ( 'test' ) ;
287+ expect ( resultTwo ) . toEqual ( 'test' ) ;
288+ } ) ;
289+
290+ it ( 'should camel case regular sentence cased strings' , ( ) => {
291+ expect ( helpers . camelCase ( 'test string' ) ) . toEqual ( 'testString' ) ;
292+ expect ( helpers . camelCase ( 'Test String' ) ) . toEqual ( 'testString' ) ;
293+ } ) ;
294+
295+ it ( 'should camel case non-alphanumeric separators' , ( ) => {
296+ expect ( helpers . camelCase ( 'dot.case' ) ) . toEqual ( 'dotCase' ) ;
297+ expect ( helpers . camelCase ( 'path/case' ) ) . toEqual ( 'pathCase' ) ;
298+ } ) ;
299+
300+ it ( 'should underscore periods inside numbers' , ( ) => {
301+ expect ( helpers . camelCase ( 'version 1.2.10' ) ) . toEqual ( 'version_1_2_10' ) ;
302+ expect ( helpers . camelCase ( 'version 1.21.0' ) ) . toEqual ( 'version_1_21_0' ) ;
303+ } ) ;
304+
305+ it ( 'should camel case pascal cased strings' , ( ) => {
306+ expect ( helpers . camelCase ( 'TestString' ) ) . toEqual ( 'testString' ) ;
307+ } ) ;
308+
309+ it ( 'should camel case non-latin strings' , ( ) => {
310+ expect ( helpers . camelCase ( 'simple éxample' ) ) . toEqual ( 'simpleÉxample' ) ;
311+ } ) ;
312+ } ) ;
313+
314+ describe ( 'paramCase' , ( ) => {
315+ it ( 'should param case a single word' , ( ) => {
316+ expect ( helpers . paramCase ( 'test' ) ) . toEqual ( 'test' ) ;
317+ expect ( helpers . paramCase ( 'TEST' ) ) . toEqual ( 'test' ) ;
318+ } ) ;
319+
320+ it ( 'should param case regular sentence cased strings' , ( ) => {
321+ expect ( helpers . paramCase ( 'test string' ) ) . toEqual ( 'test-string' ) ;
322+ expect ( helpers . paramCase ( 'Test String' ) ) . toEqual ( 'test-string' ) ;
323+ } ) ;
324+
325+ it ( 'should param case non-alphanumeric separators' , ( ) => {
326+ expect ( helpers . paramCase ( 'dot.case' ) ) . toEqual ( 'dot-case' ) ;
327+ expect ( helpers . paramCase ( 'path/case' ) ) . toEqual ( 'path-case' ) ;
328+ } ) ;
329+
330+ it ( 'should param case param cased strings' , ( ) => {
331+ expect ( helpers . paramCase ( 'TestString' ) ) . toEqual ( 'test-string' ) ;
332+ expect ( helpers . paramCase ( 'testString1_2_3' ) ) . toEqual ( 'test-string1-2-3' ) ;
333+ expect ( helpers . paramCase ( 'testString_1_2_3' ) ) . toEqual ( 'test-string-1-2-3' ) ;
334+ } ) ;
335+
336+ it ( 'should param case non-latin strings' , ( ) => {
337+ expect ( helpers . paramCase ( 'My Entrée' ) ) . toEqual ( 'my-entrée' ) ;
338+ } ) ;
339+ } ) ;
340+
341+ describe ( 'pascalCase' , ( ) => {
342+ it ( 'should pascal case a single word' , ( ) => {
343+ expect ( helpers . pascalCase ( 'test' ) ) . toEqual ( 'Test' ) ;
344+ expect ( helpers . pascalCase ( 'TEST' ) ) . toEqual ( 'Test' ) ;
345+ } ) ;
346+
347+ it ( 'should pascal case regular sentence cased strings' , ( ) => {
348+ expect ( helpers . pascalCase ( 'test string' ) ) . toEqual ( 'TestString' ) ;
349+ expect ( helpers . pascalCase ( 'Test String' ) ) . toEqual ( 'TestString' ) ;
350+ } ) ;
351+
352+ it ( 'should pascal case non-alphanumeric separators' , ( ) => {
353+ expect ( helpers . pascalCase ( 'dot.case' ) ) . toEqual ( 'DotCase' ) ;
354+ expect ( helpers . pascalCase ( 'path/case' ) ) . toEqual ( 'PathCase' ) ;
355+ } ) ;
356+
357+ it ( 'should pascal case pascal cased strings' , ( ) => {
358+ expect ( helpers . pascalCase ( 'TestString' ) ) . toEqual ( 'TestString' ) ;
359+ } ) ;
360+ } ) ;
211361} ) ;
0 commit comments