@@ -228,32 +228,50 @@ describe('"element-utils" helper', () => {
228
228
} ) ;
229
229
} ) ;
230
230
231
- describe ( 'should correctly calc web view "left" coord' , ( ) => {
232
- it ( 'with substract passed body width from web view width and take half of it' , async ( ) => {
233
- utils . getWebViewSize . withArgs ( browser ) . returns ( { width : 20 } ) ;
231
+ describe ( 'web view "left" coord' , ( ) => {
232
+ describe ( 'should correctly calc' , ( ) => {
233
+ it ( 'with substract passed body width from web view width and take half of it' , async ( ) => {
234
+ utils . getWebViewSize . withArgs ( browser ) . returns ( { width : 20 } ) ;
234
235
235
- const { left} = await utils . calcWebViewCoords ( browser , { bodyWidth : 10 } ) ;
236
+ const { left} = await utils . calcWebViewCoords ( browser , { bodyWidth : 10 } ) ;
236
237
237
- assert . equal ( left , 5 ) ;
238
+ assert . equal ( left , 5 ) ;
239
+ } ) ;
240
+
241
+ it ( 'with multiply real web view width by passed pixel ratio' , async ( ) => {
242
+ utils . getWebViewSize . withArgs ( browser ) . returns ( { width : 20 } ) ;
243
+
244
+ const { left} = await utils . calcWebViewCoords ( browser , { bodyWidth : 10 , pixelRatio : 2 } ) ;
245
+
246
+ assert . equal ( left , 10 ) ;
247
+ } ) ;
238
248
} ) ;
239
249
240
- it ( 'with multiply real web view width by passed pixel ratio ' , async ( ) => {
241
- utils . getWebViewSize . withArgs ( browser ) . returns ( { width : 20 } ) ;
250
+ it ( 'should set to zero if calculated coord is negative ' , async ( ) => {
251
+ utils . getWebViewSize . withArgs ( browser ) . returns ( { width : 10 } ) ;
242
252
243
- const { left} = await utils . calcWebViewCoords ( browser , { bodyWidth : 10 , pixelRatio : 2 } ) ;
253
+ const { left} = await utils . calcWebViewCoords ( browser , { bodyWidth : 20 } ) ;
244
254
245
- assert . equal ( left , 10 ) ;
255
+ assert . equal ( left , 0 ) ;
246
256
} ) ;
247
257
} ) ;
248
258
249
- describe ( 'should correctly calc web view "top" coord' , ( ) => {
250
- it ( 'with multiply top toolbar height by passed pixel ratio' , async ( ) => {
259
+ describe ( 'web view "top" coord' , ( ) => {
260
+ it ( 'should correctly calc with multiply top toolbar height by passed pixel ratio' , async ( ) => {
251
261
utils . getTopToolbarHeight . withArgs ( browser ) . returns ( 2 ) ;
252
262
253
263
const { top} = await utils . calcWebViewCoords ( browser , { pixelRatio : 2 } ) ;
254
264
255
265
assert . equal ( top , 4 ) ;
256
266
} ) ;
267
+
268
+ it ( 'should set to zero if calculated coord is negative' , async ( ) => {
269
+ utils . getTopToolbarHeight . withArgs ( browser ) . returns ( - 10 ) ;
270
+
271
+ const { top} = await utils . calcWebViewCoords ( browser , { pixelRatio : 1 } ) ;
272
+
273
+ assert . equal ( top , 0 ) ;
274
+ } ) ;
257
275
} ) ;
258
276
259
277
it ( 'should return "width", "height", "left" and "top" coords' , async ( ) => {
0 commit comments