File tree Expand file tree Collapse file tree 2 files changed +37
-1
lines changed Expand file tree Collapse file tree 2 files changed +37
-1
lines changed Original file line number Diff line number Diff line change @@ -75,4 +75,40 @@ describe('makeSdObject function', () => {
75
75
}
76
76
} )
77
77
} )
78
+
79
+ it ( 'should camelCase values when setCasing is not given' , ( ) => {
80
+ const obj : { [ key : string ] : string } = {
81
+ 'foo.foo-bar' : 'bar' ,
82
+ }
83
+
84
+ const result = { }
85
+ Object . keys ( obj ) . forEach ( ( key ) => {
86
+ const keys = key . split ( '.' ) . filter ( ( k ) => k !== 'colors' )
87
+ makeSdObject ( result , keys , obj [ key ] )
88
+ } )
89
+
90
+ expect ( result ) . toEqual ( {
91
+ foo : {
92
+ fooBar : 'bar'
93
+ }
94
+ } )
95
+ } )
96
+
97
+ it ( 'should not camelCase when setCasing is set to false' , ( ) => {
98
+ const obj : { [ key : string ] : string } = {
99
+ 'typography.foo-bar' : 'bar' ,
100
+ }
101
+
102
+ const result = { }
103
+ Object . keys ( obj ) . forEach ( ( key ) => {
104
+ const keys = key . split ( '.' ) . filter ( ( k ) => k !== 'colors' )
105
+ makeSdObject ( result , keys , obj [ key ] , false )
106
+ } )
107
+
108
+ expect ( result ) . toEqual ( {
109
+ typography : {
110
+ 'foo-bar' : 'bar'
111
+ }
112
+ } )
113
+ } )
78
114
} )
Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ export const makeSdObject = <T extends readonly string[]>(
9
9
obj : SdObjType < { [ key : string ] : any } > ,
10
10
keys : T ,
11
11
value : string ,
12
- setCasing : boolean
12
+ setCasing = true
13
13
) : void => {
14
14
const lastIndex = keys . length - 1
15
15
for ( let i = 0 ; i < lastIndex ; ++ i ) {
You can’t perform that action at this time.
0 commit comments