This repository was archived by the owner on May 1, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -359,4 +359,19 @@ describe('helpers', () => {
359
359
} ) ;
360
360
} ) ;
361
361
362
+ describe ( 'snakeCase' , ( ) => {
363
+ it ( 'should convert the phrase to use underscores' , ( ) => {
364
+ expect ( helpers . snakeCase ( 'taco bell' ) ) . toEqual ( 'taco_bell' ) ;
365
+ } ) ;
366
+ } ) ;
367
+
368
+ describe ( 'constantCase' , ( ) => {
369
+ it ( 'should capitalize and separate words by underscore' , ( ) => {
370
+ expect ( helpers . constantCase ( 'taco bell' ) ) . toEqual ( 'TACO_BELL' ) ;
371
+ } ) ;
372
+
373
+ it ( 'should convert camel case to correct case' , ( ) => {
374
+ expect ( helpers . constantCase ( 'TacoBell' ) ) . toEqual ( 'TACO_BELL' ) ;
375
+ } ) ;
376
+ } ) ;
362
377
} ) ;
Original file line number Diff line number Diff line change @@ -410,6 +410,14 @@ export function sentenceCase(input: string) {
410
410
return upperCaseFirst ( noCase ) ;
411
411
}
412
412
413
+ export function snakeCase ( input : string ) {
414
+ return removeCaseFromString ( input , '_' ) ;
415
+ }
416
+
417
+ export function constantCase ( input : string ) {
418
+ return snakeCase ( input ) . toUpperCase ( ) ;
419
+ }
420
+
413
421
export function camelCase ( input : string ) {
414
422
input = removeCaseFromString ( input ) ;
415
423
input = input . replace ( / (? = \d ) / g, '_' ) ;
You can’t perform that action at this time.
0 commit comments