File tree Expand file tree Collapse file tree
packages/fela-plugin-extend/src Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -143,6 +143,94 @@ describe('Extend plugin', () => {
143143 } )
144144 } )
145145
146+ it ( 'should merge multiple nested extensions' , ( ) => {
147+ const base = {
148+ color : 'blue' ,
149+ backgroundColor : 'red' ,
150+ extend : {
151+ color : 'green' ,
152+ fontSize : 15 ,
153+ extend : {
154+ lineHeight : 1.0 ,
155+ } ,
156+ } ,
157+ }
158+
159+ expect ( extend ( ) ( base ) ) . toEqual ( {
160+ color : 'blue' ,
161+ backgroundColor : 'red' ,
162+ color : 'green' ,
163+ fontSize : 15 ,
164+ lineHeight : 1.0 ,
165+ } )
166+ } )
167+
168+ it ( 'should merge multiple nested conditional extensions' , ( ) => {
169+ const base = {
170+ color : 'blue' ,
171+ backgroundColor : 'red' ,
172+ extend : {
173+ condition : true ,
174+ style : {
175+ color : 'green' ,
176+ fontSize : 15 ,
177+ extend : {
178+ condition : true ,
179+ style : {
180+ lineHeight : 1.0 ,
181+ } ,
182+ } ,
183+ } ,
184+ } ,
185+ }
186+
187+ expect ( extend ( ) ( base ) ) . toEqual ( {
188+ color : 'blue' ,
189+ backgroundColor : 'red' ,
190+ color : 'green' ,
191+ fontSize : 15 ,
192+ lineHeight : 1.0 ,
193+ } )
194+ } )
195+
196+ it ( 'should merge multiple nested conditional extensions' , ( ) => {
197+ const base = {
198+ color : 'blue' ,
199+ backgroundColor : 'red' ,
200+ extend : [
201+ {
202+ condition : true ,
203+ style : {
204+ color : 'green' ,
205+ fontSize : 15 ,
206+ extend : {
207+ condition : true ,
208+ style : {
209+ lineHeight : 1.0 ,
210+ } ,
211+ } ,
212+ } ,
213+ } ,
214+ {
215+ paddingLeft : 10 ,
216+ extend : {
217+ paddingRight : 10 ,
218+ } ,
219+ } ,
220+ ] ,
221+ }
222+
223+ expect ( extend ( ) ( base ) ) . toEqual ( {
224+ color : 'blue' ,
225+ backgroundColor : 'red' ,
226+ color : 'green' ,
227+ fontSize : 15 ,
228+ lineHeight : 1.0 ,
229+ paddingLeft : 10 ,
230+ paddingRight : 10 ,
231+ } )
232+ } )
233+
146234 it ( 'should not convert null values to empty objects' , ( ) => {
147235 const base = {
148236 color : 'blue' ,
Original file line number Diff line number Diff line change @@ -32,7 +32,7 @@ function extendStyle(style: Object, extension: Object): void {
3232 }
3333 } else {
3434 // extend basic style objects
35- assignStyle ( style , removeUndefined ( extension ) )
35+ assignStyle ( style , removeUndefined ( extend ( extension ) ) )
3636 }
3737}
3838
You can’t perform that action at this time.
0 commit comments