@@ -26,6 +26,7 @@ describe('given a <ParallaxBanner> component', () => {
26
26
expect ( asFragment ( ) ) . toMatchSnapshot ( ) ;
27
27
} ) ;
28
28
} ) ;
29
+
29
30
describe . each ( ALL_PARALLAX_PROPS ) ( 'when the prop %s is given' , ( props ) => {
30
31
it ( 'then it renders without issue and calls create element with props' , ( ) => {
31
32
const controller = ParallaxController . init ( {
@@ -48,7 +49,11 @@ describe('given a <ParallaxBanner> component', () => {
48
49
expect ( asFragment ( ) ) . toMatchSnapshot ( ) ;
49
50
expect ( controller . createElement ) . toBeCalledWith ( {
50
51
el : expect . any ( HTMLElement ) ,
51
- props : { ...props , shouldDisableScalingTranslations : true } ,
52
+ props : {
53
+ ...props ,
54
+ shouldDisableScalingTranslations : true ,
55
+ targetElement : expect . any ( HTMLElement ) ,
56
+ } ,
52
57
} ) ;
53
58
} ) ;
54
59
} ) ;
@@ -73,6 +78,7 @@ describe('given a <ParallaxBanner> component', () => {
73
78
el : expect . any ( HTMLElement ) ,
74
79
props : {
75
80
shouldDisableScalingTranslations : true ,
81
+ targetElement : expect . any ( HTMLElement ) ,
76
82
} ,
77
83
} ) ;
78
84
} ) ;
@@ -121,18 +127,76 @@ describe('given a <ParallaxBanner> component', () => {
121
127
} ) ;
122
128
} ) ;
123
129
124
- describe ( 'with layer expanded' , ( ) => {
125
- it ( 'then it will render with expanded styles based on speed' , ( ) => {
126
- const { getByTestId } = render (
127
- < ParallaxProvider >
128
- < ParallaxBanner layers = { [ { speed : 2 } ] } />
129
- </ ParallaxProvider >
130
- ) ;
131
- expect ( getByTestId ( 'layer-0' ) . style . top ) . toBe ( '-20px' ) ;
132
- expect ( getByTestId ( 'layer-0' ) . style . right ) . toBe ( '0px' ) ;
133
- expect ( getByTestId ( 'layer-0' ) . style . left ) . toBe ( '0px' ) ;
134
- expect ( getByTestId ( 'layer-0' ) . style . bottom ) . toBe ( '-20px' ) ;
135
- expect ( getByTestId ( 'layer-0' ) . style . position ) . toBe ( 'absolute' ) ;
130
+ describe ( 'when the layer is expanded and' , ( ) => {
131
+ describe ( 'when the speed prop is set to a positive number' , ( ) => {
132
+ it ( 'then it will render with expanded styles based on speed' , ( ) => {
133
+ const { getByTestId } = render (
134
+ < ParallaxProvider >
135
+ < ParallaxBanner layers = { [ { speed : 2 } ] } />
136
+ </ ParallaxProvider >
137
+ ) ;
138
+ expect ( getByTestId ( 'layer-0' ) . style . top ) . toBe ( '-20px' ) ;
139
+ expect ( getByTestId ( 'layer-0' ) . style . right ) . toBe ( '0px' ) ;
140
+ expect ( getByTestId ( 'layer-0' ) . style . left ) . toBe ( '0px' ) ;
141
+ expect ( getByTestId ( 'layer-0' ) . style . bottom ) . toBe ( '-20px' ) ;
142
+ expect ( getByTestId ( 'layer-0' ) . style . position ) . toBe ( 'absolute' ) ;
143
+ } ) ;
144
+ } ) ;
145
+ describe ( 'when the speed prop is set to a negative number' , ( ) => {
146
+ it ( 'then it will render with expanded styles based on speed' , ( ) => {
147
+ const { getByTestId } = render (
148
+ < ParallaxProvider >
149
+ < ParallaxBanner layers = { [ { speed : - 4 } ] } />
150
+ </ ParallaxProvider >
151
+ ) ;
152
+ expect ( getByTestId ( 'layer-0' ) . style . top ) . toBe ( '-40px' ) ;
153
+ expect ( getByTestId ( 'layer-0' ) . style . right ) . toBe ( '0px' ) ;
154
+ expect ( getByTestId ( 'layer-0' ) . style . left ) . toBe ( '0px' ) ;
155
+ expect ( getByTestId ( 'layer-0' ) . style . bottom ) . toBe ( '-40px' ) ;
156
+ expect ( getByTestId ( 'layer-0' ) . style . position ) . toBe ( 'absolute' ) ;
157
+ } ) ;
158
+ } ) ;
159
+ describe ( 'when the translateY prop is set [0px, 10px]' , ( ) => {
160
+ it ( 'then it will render with expanded styles based on the translate start end values' , ( ) => {
161
+ const { getByTestId } = render (
162
+ < ParallaxProvider >
163
+ < ParallaxBanner layers = { [ { translateY : [ '0px' , '10px' ] } ] } />
164
+ </ ParallaxProvider >
165
+ ) ;
166
+ expect ( getByTestId ( 'layer-0' ) . style . top ) . toBe ( '-10px' ) ;
167
+ expect ( getByTestId ( 'layer-0' ) . style . right ) . toBe ( '0px' ) ;
168
+ expect ( getByTestId ( 'layer-0' ) . style . left ) . toBe ( '0px' ) ;
169
+ expect ( getByTestId ( 'layer-0' ) . style . bottom ) . toBe ( '0px' ) ;
170
+ expect ( getByTestId ( 'layer-0' ) . style . position ) . toBe ( 'absolute' ) ;
171
+ } ) ;
172
+ } ) ;
173
+ describe ( 'when the translateY prop is set [-40px, 30px]' , ( ) => {
174
+ it ( 'then it will render with expanded styles based on the translate start end values' , ( ) => {
175
+ const { getByTestId } = render (
176
+ < ParallaxProvider >
177
+ < ParallaxBanner layers = { [ { translateY : [ '-40px' , '30px' ] } ] } />
178
+ </ ParallaxProvider >
179
+ ) ;
180
+ expect ( getByTestId ( 'layer-0' ) . style . top ) . toBe ( '-30px' ) ;
181
+ expect ( getByTestId ( 'layer-0' ) . style . right ) . toBe ( '0px' ) ;
182
+ expect ( getByTestId ( 'layer-0' ) . style . left ) . toBe ( '0px' ) ;
183
+ expect ( getByTestId ( 'layer-0' ) . style . bottom ) . toBe ( '-40px' ) ;
184
+ expect ( getByTestId ( 'layer-0' ) . style . position ) . toBe ( 'absolute' ) ;
185
+ } ) ;
186
+ } ) ;
187
+ describe ( 'when the translateY prop is set [0px, 100px]' , ( ) => {
188
+ it ( 'then it will render with expanded styles based on the translate start end values' , ( ) => {
189
+ const { getByTestId } = render (
190
+ < ParallaxProvider >
191
+ < ParallaxBanner layers = { [ { translateY : [ '0px' , '100px' ] } ] } />
192
+ </ ParallaxProvider >
193
+ ) ;
194
+ expect ( getByTestId ( 'layer-0' ) . style . top ) . toBe ( '-100px' ) ;
195
+ expect ( getByTestId ( 'layer-0' ) . style . right ) . toBe ( '0px' ) ;
196
+ expect ( getByTestId ( 'layer-0' ) . style . left ) . toBe ( '0px' ) ;
197
+ expect ( getByTestId ( 'layer-0' ) . style . bottom ) . toBe ( '0px' ) ;
198
+ expect ( getByTestId ( 'layer-0' ) . style . position ) . toBe ( 'absolute' ) ;
199
+ } ) ;
136
200
} ) ;
137
201
} ) ;
138
202
describe ( 'with custom props' , ( ) => {
0 commit comments