@@ -48,10 +48,16 @@ const themeWithVariant = {
4848 } ,
4949} ;
5050
51+ const themeWithoutSpacing = {
52+ ...theme ,
53+ spacing : undefined ,
54+ } ;
55+
5156const { breakpoints, ...themeWithoutBreakpoints } = theme ;
5257
5358type Theme = typeof theme ;
5459type ThemeWithVariant = typeof themeWithVariant ;
60+ type ThemeWithoutSpacing = typeof themeWithoutSpacing ;
5561
5662const mockUseWindowDimensions = jest . fn ( ) ;
5763
@@ -67,6 +73,14 @@ const Component = createRestyleComponent<
6773 ViewProps ,
6874 Theme
6975> ( [ backgroundColor , spacing , spacingShorthand , opacity ] ) ;
76+ const ComponentWithoutSpacing = createRestyleComponent <
77+ BackgroundColorProps < ThemeWithoutSpacing > &
78+ SpacingProps < ThemeWithoutSpacing > &
79+ SpacingShorthandProps < ThemeWithoutSpacing > &
80+ OpacityProps < ThemeWithoutSpacing > &
81+ ViewProps ,
82+ ThemeWithoutSpacing
83+ > ( [ backgroundColor , spacing , spacingShorthand , opacity ] ) ;
7084const cardVariant = createVariant < ThemeWithVariant , 'cardVariants' > ( {
7185 themeKey : 'cardVariants' ,
7286} ) ;
@@ -230,5 +244,24 @@ describe('createRestyleComponent', () => {
230244 style : [ { gap : 8 , columnGap : 8 , rowGap : 8 } ] ,
231245 } ) ;
232246 } ) ;
247+
248+ it ( 'passes gap values from the theme when no spacing prop is defined' , ( ) => {
249+ const { root} = render (
250+ < ThemeProvider theme = { themeWithoutSpacing } >
251+ < ComponentWithoutSpacing
252+ gap = { 10 }
253+ columnGap = { 20 }
254+ rowGap = { 22 }
255+ marginTop = { 2 }
256+ paddingBottom = { 3 }
257+ />
258+ </ ThemeProvider > ,
259+ ) ;
260+ expect ( root . findByType ( View ) . props ) . toStrictEqual ( {
261+ style : [
262+ { gap : 10 , columnGap : 20 , rowGap : 22 , marginTop : 2 , paddingBottom : 3 } ,
263+ ] ,
264+ } ) ;
265+ } ) ;
233266 } ) ;
234267} ) ;
0 commit comments