@@ -39,6 +39,88 @@ describe('Surface', () => {
39
39
} ,
40
40
} ) ;
41
41
42
+ it . each `
43
+ property | value
44
+ ${ 'opacity' } | ${ 0.7 }
45
+ ${ 'transform' } | ${ [ { scale : 1.02 } ] }
46
+ ${ 'width' } | ${ '42%' }
47
+ ${ 'height' } | ${ '32.5%' }
48
+ ${ 'margin' } | ${ 13 }
49
+ ${ 'marginLeft' } | ${ 13.1 }
50
+ ${ 'marginRight' } | ${ 13.2 }
51
+ ${ 'marginTop' } | ${ 13.3 }
52
+ ${ 'marginBottom' } | ${ 13.4 }
53
+ ${ 'marginHorizontal' } | ${ 13.5 }
54
+ ${ 'marginVertical' } | ${ 13.6 }
55
+ ${ 'position' } | ${ 'absolute' }
56
+ ${ 'alignSelf' } | ${ 'flex-start' }
57
+ ${ 'top' } | ${ 1.1 }
58
+ ${ 'right' } | ${ 1.2 }
59
+ ${ 'bottom' } | ${ 1.3 }
60
+ ${ 'left' } | ${ 1.4 }
61
+ ${ 'start' } | ${ 1.5 }
62
+ ${ 'end' } | ${ 1.6 }
63
+ ${ 'flex' } | ${ 6 }
64
+ ` ( 'applies $property to outer layer only' , ( { property, value } ) => {
65
+ const style = { [ property ] : value } ;
66
+
67
+ const { getByTestId } = render (
68
+ < Surface testID = "surface-test" style = { style } >
69
+ { null }
70
+ </ Surface >
71
+ ) ;
72
+
73
+ expect ( getByTestId ( 'surface-test-outer-layer' ) ) . toHaveStyle ( style ) ;
74
+ expect ( getByTestId ( 'surface-test-middle-layer' ) ) . not . toHaveStyle ( style ) ;
75
+ expect ( getByTestId ( 'surface-test' ) ) . not . toHaveStyle ( style ) ;
76
+ } ) ;
77
+
78
+ it . each `
79
+ property | value
80
+ ${ 'padding' } | ${ 12 }
81
+ ${ 'paddingLeft' } | ${ 12.1 }
82
+ ${ 'paddingRight' } | ${ 12.2 }
83
+ ${ 'paddingTop' } | ${ 12.3 }
84
+ ${ 'paddingBottom' } | ${ 12.4 }
85
+ ${ 'paddingHorizontal' } | ${ 12.5 }
86
+ ${ 'paddingVertical' } | ${ 12.6 }
87
+ ${ 'borderWidth' } | ${ 2 }
88
+ ${ 'borderColor' } | ${ 'black' }
89
+ ` ( 'applies $property to inner layer only' , ( { property, value } ) => {
90
+ const style = { [ property ] : value } ;
91
+
92
+ const { getByTestId } = render (
93
+ < Surface testID = "surface-test" style = { style } >
94
+ { null }
95
+ </ Surface >
96
+ ) ;
97
+
98
+ expect ( getByTestId ( 'surface-test-outer-layer' ) ) . not . toHaveStyle ( style ) ;
99
+ expect ( getByTestId ( 'surface-test-middle-layer' ) ) . not . toHaveStyle ( style ) ;
100
+ expect ( getByTestId ( 'surface-test' ) ) . toHaveStyle ( style ) ;
101
+ } ) ;
102
+
103
+ it . each `
104
+ property | value
105
+ ${ 'borderRadius' } | ${ 3 }
106
+ ${ 'borderTopLeftRadius' } | ${ 1 }
107
+ ${ 'borderTopRightRadius' } | ${ 2 }
108
+ ${ 'borderBottomLeftRadius' } | ${ 3 }
109
+ ${ 'borderBottomRightRadius' } | ${ 4 }
110
+ ` ( 'applies $property to every layer' , ( { property, value } ) => {
111
+ const style = { [ property ] : value } ;
112
+
113
+ const { getByTestId } = render (
114
+ < Surface testID = "surface-test" style = { style } >
115
+ { null }
116
+ </ Surface >
117
+ ) ;
118
+
119
+ expect ( getByTestId ( 'surface-test-outer-layer' ) ) . toHaveStyle ( style ) ;
120
+ expect ( getByTestId ( 'surface-test-middle-layer' ) ) . toHaveStyle ( style ) ;
121
+ expect ( getByTestId ( 'surface-test' ) ) . toHaveStyle ( style ) ;
122
+ } ) ;
123
+
42
124
describe ( 'outer layer' , ( ) => {
43
125
it ( 'should not render rest style' , ( ) => {
44
126
const testID = 'surface-test' ;
0 commit comments