@applicaster/zapp-react-native-utils 14.0.0-alpha.6242515303 → 14.0.0-alpha.6461844364
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/analyticsUtils/AnalyticsEvents/sendHeaderClickEvent.ts +1 -1
- package/analyticsUtils/AnalyticsEvents/sendMenuClickEvent.ts +2 -1
- package/analyticsUtils/index.tsx +3 -4
- package/analyticsUtils/manager.ts +1 -1
- package/appUtils/accessibilityManager/index.ts +12 -3
- package/configurationUtils/__tests__/manifestKeyParser.test.ts +547 -0
- package/configurationUtils/manifestKeyParser.ts +57 -32
- package/index.d.ts +0 -9
- package/manifestUtils/defaultManifestConfigurations/player.js +0 -148
- package/manifestUtils/keys.js +0 -12
- package/manifestUtils/sharedConfiguration/screenPicker/stylesFields.js +0 -6
- package/package.json +2 -2
- package/playerUtils/index.ts +51 -0
- package/reactHooks/autoscrolling/__tests__/useTrackedView.test.tsx +12 -13
- package/reactHooks/feed/__tests__/useBatchLoading.test.tsx +39 -88
- package/reactHooks/layout/isTablet/index.ts +7 -3
- package/reactHooks/navigation/index.ts +7 -5
- package/testUtils/index.tsx +7 -8
|
@@ -11,8 +11,11 @@ const currentPlatform = platformSelect({
|
|
|
11
11
|
android_tv: "android",
|
|
12
12
|
});
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
// Do not change the order, focused_selected should be first
|
|
15
|
+
const states = ["focused_selected", "pressed", "focused", "selected"];
|
|
16
|
+
|
|
15
17
|
const platformSuffixes = ["ios", "tvos", "samsung", "lg", "android"];
|
|
18
|
+
type StateKey = (typeof states)[number] | "default";
|
|
16
19
|
|
|
17
20
|
export type GetAllSpecificStylesProps = {
|
|
18
21
|
componentName: string;
|
|
@@ -33,39 +36,47 @@ export const getAllSpecificStyles = ({
|
|
|
33
36
|
subComponentName,
|
|
34
37
|
outStyles,
|
|
35
38
|
}: GetAllSpecificStylesProps) => {
|
|
36
|
-
if (!outStyles)
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
+
if (!outStyles) throw new Error("outStyles is required");
|
|
40
|
+
if (!componentName) throw new Error("componentName is required");
|
|
39
41
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
+
const prefix =
|
|
43
|
+
subComponentName?.length > 0
|
|
44
|
+
? `${componentName}_style_${subComponentName}_`
|
|
45
|
+
: `${componentName}_style_`;
|
|
42
46
|
|
|
43
47
|
const defaultKey = "default";
|
|
44
48
|
|
|
45
|
-
if (!outStyles[defaultKey]) {
|
|
46
|
-
|
|
47
|
-
}
|
|
49
|
+
if (!outStyles[defaultKey]) outStyles[defaultKey] = {};
|
|
50
|
+
|
|
51
|
+
const tmpGenericDict: Record<StateKey, Record<string, any>> = {};
|
|
52
|
+
const tmpPlatformDict: Record<StateKey, Record<string, any>> = {};
|
|
48
53
|
|
|
49
|
-
|
|
54
|
+
const parseKey = (key: string, value: any) => {
|
|
50
55
|
if (!key.startsWith(prefix)) {
|
|
51
56
|
return;
|
|
52
57
|
}
|
|
53
58
|
|
|
54
59
|
let styleName = key.slice(prefix.length);
|
|
60
|
+
if (!styleName || styleName.startsWith("_")) return;
|
|
55
61
|
|
|
56
|
-
const platform = platformSuffixes.find((
|
|
57
|
-
styleName.startsWith(
|
|
62
|
+
const platform = platformSuffixes.find((prefix) =>
|
|
63
|
+
styleName.startsWith(prefix)
|
|
58
64
|
);
|
|
59
65
|
|
|
66
|
+
let tmpDict = tmpGenericDict;
|
|
67
|
+
|
|
60
68
|
if (platform) {
|
|
61
69
|
if (currentPlatform !== platform) {
|
|
62
|
-
return;
|
|
70
|
+
return;
|
|
63
71
|
}
|
|
64
72
|
|
|
73
|
+
tmpDict = tmpPlatformDict;
|
|
65
74
|
styleName = styleName.slice(platform.length + 1);
|
|
66
75
|
}
|
|
67
76
|
|
|
68
|
-
let state =
|
|
77
|
+
let state = states.find((prefix) => styleName.startsWith(prefix)) as
|
|
78
|
+
| StateKey
|
|
79
|
+
| undefined;
|
|
69
80
|
|
|
70
81
|
if (state) {
|
|
71
82
|
styleName = styleName.slice(state.length + 1);
|
|
@@ -73,30 +84,44 @@ export const getAllSpecificStyles = ({
|
|
|
73
84
|
state = defaultKey;
|
|
74
85
|
}
|
|
75
86
|
|
|
76
|
-
|
|
87
|
+
if (!styleName) return;
|
|
77
88
|
|
|
78
|
-
|
|
89
|
+
const camelCaseKey = toCamelCase(styleName);
|
|
79
90
|
|
|
80
|
-
if (!
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
}
|
|
91
|
+
if (!tmpDict[state]) tmpDict[state] = {};
|
|
92
|
+
tmpDict[state][camelCaseKey] = value;
|
|
93
|
+
};
|
|
84
94
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
95
|
+
for (const [key, value] of Object.entries(configuration)) {
|
|
96
|
+
parseKey(key, value);
|
|
97
|
+
}
|
|
88
98
|
|
|
89
|
-
|
|
90
|
-
|
|
99
|
+
const allStates = Array.from(
|
|
100
|
+
new Set<StateKey>([
|
|
101
|
+
defaultKey,
|
|
102
|
+
...(Object.keys(tmpGenericDict) as StateKey[]),
|
|
103
|
+
...(Object.keys(tmpPlatformDict) as StateKey[]),
|
|
104
|
+
...(Object.keys(outStyles) as StateKey[]),
|
|
105
|
+
])
|
|
106
|
+
);
|
|
107
|
+
|
|
108
|
+
for (const state of allStates) {
|
|
109
|
+
outStyles[state] = Object.assign(
|
|
110
|
+
{},
|
|
111
|
+
outStyles[state] || {},
|
|
112
|
+
tmpGenericDict[state] || {},
|
|
113
|
+
tmpPlatformDict[state] || {}
|
|
114
|
+
);
|
|
115
|
+
}
|
|
91
116
|
|
|
92
117
|
// Merge default styles with state specific styles
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
if (key === defaultKey) {
|
|
96
|
-
return;
|
|
97
|
-
}
|
|
118
|
+
for (const state of Object.keys(outStyles)) {
|
|
119
|
+
if (state === defaultKey) continue;
|
|
98
120
|
|
|
99
|
-
|
|
100
|
-
|
|
121
|
+
outStyles[state] = Object.assign(
|
|
122
|
+
{},
|
|
123
|
+
outStyles[defaultKey],
|
|
124
|
+
outStyles[state]
|
|
125
|
+
);
|
|
101
126
|
}
|
|
102
127
|
};
|
package/index.d.ts
CHANGED
|
@@ -137,12 +137,3 @@ declare type AccessibilityState = {
|
|
|
137
137
|
reduceMotionEnabled: boolean;
|
|
138
138
|
boldTextEnabled: boolean;
|
|
139
139
|
};
|
|
140
|
-
|
|
141
|
-
declare type AccessibilityProps = {
|
|
142
|
-
accessibilityLabel?: string;
|
|
143
|
-
accessibilityHint?: string;
|
|
144
|
-
"aria-label"?: string;
|
|
145
|
-
"aria-description"?: string;
|
|
146
|
-
accessibilityRole?: string;
|
|
147
|
-
"aria-role"?: string;
|
|
148
|
-
};
|
|
@@ -351,86 +351,6 @@ function getPlayerConfiguration({ platform, version }) {
|
|
|
351
351
|
],
|
|
352
352
|
},
|
|
353
353
|
]),
|
|
354
|
-
fieldsGroup(
|
|
355
|
-
"Partial Player (Roku only)",
|
|
356
|
-
"This section allows you to configure width and height of video player in Partial Player",
|
|
357
|
-
[
|
|
358
|
-
{
|
|
359
|
-
key: "video_theater_width",
|
|
360
|
-
label: "Width of player",
|
|
361
|
-
type: "number_input",
|
|
362
|
-
initial_value: "1420",
|
|
363
|
-
placeHolder: "1420",
|
|
364
|
-
},
|
|
365
|
-
{
|
|
366
|
-
key: "video_theater_height",
|
|
367
|
-
label: "Height of player",
|
|
368
|
-
type: "number_input",
|
|
369
|
-
initial_value: "900",
|
|
370
|
-
placeHolder: "900",
|
|
371
|
-
},
|
|
372
|
-
{
|
|
373
|
-
key: "full_screen_button_offset_x",
|
|
374
|
-
label: "Fullscreen button X",
|
|
375
|
-
type: "number_input",
|
|
376
|
-
initial_value: 160,
|
|
377
|
-
placeHolder: "160",
|
|
378
|
-
},
|
|
379
|
-
{
|
|
380
|
-
key: "full_screen_button_offset_y",
|
|
381
|
-
label: "Fullscreen button Y",
|
|
382
|
-
type: "number_input",
|
|
383
|
-
initial_value: 160,
|
|
384
|
-
placeHolder: "160",
|
|
385
|
-
},
|
|
386
|
-
{
|
|
387
|
-
key: "full_screen_button_w",
|
|
388
|
-
label: "Fullscreen button width",
|
|
389
|
-
type: "number_input",
|
|
390
|
-
initial_value: 120,
|
|
391
|
-
placeHolder: "120",
|
|
392
|
-
},
|
|
393
|
-
{
|
|
394
|
-
key: "full_screen_button_h",
|
|
395
|
-
label: "Fullscreen button height",
|
|
396
|
-
type: "number_input",
|
|
397
|
-
initial_value: 120,
|
|
398
|
-
placeHolder: "120",
|
|
399
|
-
},
|
|
400
|
-
{
|
|
401
|
-
key: "full_screen_button_background_color",
|
|
402
|
-
type: "color_picker",
|
|
403
|
-
label: "Fullscreen Button background color",
|
|
404
|
-
initial_value: "#00000000",
|
|
405
|
-
placeHolder: "color",
|
|
406
|
-
label_tooltip: "Pick Color",
|
|
407
|
-
},
|
|
408
|
-
{
|
|
409
|
-
key: "full_screen_button_background_url",
|
|
410
|
-
type: "text_input",
|
|
411
|
-
label: "Fullscreen Button background Url",
|
|
412
|
-
initial_value: "pkg:/images/tv_fullscreen.png",
|
|
413
|
-
placeHolder: "",
|
|
414
|
-
label_tooltip: "",
|
|
415
|
-
},
|
|
416
|
-
{
|
|
417
|
-
key: "full_screen_button_highlighted_background_color",
|
|
418
|
-
type: "color_picker",
|
|
419
|
-
label: "Fullscreen Button highlighted background color",
|
|
420
|
-
initial_value: "#00000000",
|
|
421
|
-
placeHolder: "color",
|
|
422
|
-
label_tooltip: "Pick Color",
|
|
423
|
-
},
|
|
424
|
-
{
|
|
425
|
-
key: "full_screen_button_highlighted_background_url",
|
|
426
|
-
type: "text_input",
|
|
427
|
-
label: "Fullscreen Button highlighted Url",
|
|
428
|
-
initial_value: "pkg:/images/tv_fullscreen.png",
|
|
429
|
-
placeHolder: "",
|
|
430
|
-
label_tooltip: "",
|
|
431
|
-
},
|
|
432
|
-
]
|
|
433
|
-
),
|
|
434
354
|
fieldsGroup(
|
|
435
355
|
"Skip Button",
|
|
436
356
|
"This section allows you to configure the skip button styles for tv",
|
|
@@ -562,20 +482,6 @@ function getPlayerConfiguration({ platform, version }) {
|
|
|
562
482
|
key: "skip_button_style_text_android_font_size",
|
|
563
483
|
initial_value: 24,
|
|
564
484
|
},
|
|
565
|
-
{
|
|
566
|
-
type: "roku_font_selector",
|
|
567
|
-
label_tooltip: "",
|
|
568
|
-
label: "Android Font Family",
|
|
569
|
-
key: "skip_button_style_text_roku_font_family",
|
|
570
|
-
initial_value: "Ubuntu-Bold",
|
|
571
|
-
},
|
|
572
|
-
{
|
|
573
|
-
type: "number_input",
|
|
574
|
-
label_tooltip: "",
|
|
575
|
-
label: "Roku Font Size",
|
|
576
|
-
key: "skip_button_style_text_roku_font_size",
|
|
577
|
-
initial_value: 24,
|
|
578
|
-
},
|
|
579
485
|
{
|
|
580
486
|
type: "select",
|
|
581
487
|
options: [
|
|
@@ -3424,60 +3330,6 @@ function getPlayerConfiguration({ platform, version }) {
|
|
|
3424
3330
|
},
|
|
3425
3331
|
]
|
|
3426
3332
|
),
|
|
3427
|
-
fieldsGroup(
|
|
3428
|
-
"Roku only",
|
|
3429
|
-
"This section allows you to configure RAF - Roku Ad Framework settings",
|
|
3430
|
-
[
|
|
3431
|
-
{
|
|
3432
|
-
key: "raf_enabled",
|
|
3433
|
-
type: "switch",
|
|
3434
|
-
initial_value: false,
|
|
3435
|
-
},
|
|
3436
|
-
{
|
|
3437
|
-
key: "raf_url",
|
|
3438
|
-
type: "text_input",
|
|
3439
|
-
label: "Ad Url",
|
|
3440
|
-
label_tooltip:
|
|
3441
|
-
"Publisher's ad URL. The default is he roku ad server with single preroll placeholder, with revenue spilt ad sharing by default. TO GET PAID A URL MUST BE PASSED IN HERE. Note: If you are putting ads in child targetted content then your ad url will have to use the ROKU_ADS_KIDS_CONTENT macro value, as per the docs here: developer.roku.com/docs/developer-program/advertising/integrating-roku-advertising-framework.md#url-parameter-macros",
|
|
3442
|
-
},
|
|
3443
|
-
{
|
|
3444
|
-
key: "genre",
|
|
3445
|
-
type: "text_input",
|
|
3446
|
-
label: "Roku Genre",
|
|
3447
|
-
initial_value: "Entertainment",
|
|
3448
|
-
label_tooltip:
|
|
3449
|
-
"Choose value from Roku genre tags, from developer.roku.com/en-gb/docs/developer-program/advertising/integrating-roku-advertising-framework.md",
|
|
3450
|
-
},
|
|
3451
|
-
{
|
|
3452
|
-
key: "nielsen_enabled",
|
|
3453
|
-
type: "checkbox",
|
|
3454
|
-
initial_value: false,
|
|
3455
|
-
label_tooltip:
|
|
3456
|
-
"Required only for apps launched in the US market, See developer.roku.com/en-gb/docs/developer-program/advertising/integrating-roku-advertising-framework.md for details on configuration",
|
|
3457
|
-
},
|
|
3458
|
-
{
|
|
3459
|
-
key: "nielsen_app_id",
|
|
3460
|
-
type: "text_input",
|
|
3461
|
-
initial_value: "",
|
|
3462
|
-
label_tooltip:
|
|
3463
|
-
"id of your app for nielsen leave blank if you don't have a specific id (that is almost always the case)",
|
|
3464
|
-
},
|
|
3465
|
-
{
|
|
3466
|
-
key: "nielsen_genre",
|
|
3467
|
-
type: "text_input",
|
|
3468
|
-
initial_value: "General",
|
|
3469
|
-
label_tooltip:
|
|
3470
|
-
"genre from developer.roku.com/en-gb/docs/developer-program/advertising/integrating-roku-advertising-framework.md#nielsen-dar-genre-tags",
|
|
3471
|
-
},
|
|
3472
|
-
{
|
|
3473
|
-
key: "is_kids_content",
|
|
3474
|
-
type: "checkbox",
|
|
3475
|
-
initial_value: false,
|
|
3476
|
-
label_tooltip:
|
|
3477
|
-
"If your content is directed at kids, this must be checked. See developer.roku.com/docs/developer-program/advertising/raf-api.md#setcontentgenregenres-as-string-kidscontent-as-boolean for more info. Also note your ad urls will have to use the ROKU_ADS_KIDS_CONTENT macro value, as per the docs here: developer.roku.com/docs/developer-program/advertising/integrating-roku-advertising-framework.md#url-parameter-macros",
|
|
3478
|
-
},
|
|
3479
|
-
]
|
|
3480
|
-
),
|
|
3481
3333
|
fieldsGroup(
|
|
3482
3334
|
"Audio Tracks",
|
|
3483
3335
|
"This section allows you to configure default audio track behavior for videos with multiple audio tracks",
|
package/manifestUtils/keys.js
CHANGED
|
@@ -485,18 +485,6 @@ const TV_MENU_LABEL_FIELDS = [
|
|
|
485
485
|
type: ZAPPIFEST_FIELDS.number_input,
|
|
486
486
|
suffix: "LG letter spacing",
|
|
487
487
|
},
|
|
488
|
-
{
|
|
489
|
-
type: ZAPPIFEST_FIELDS.font_selector.roku,
|
|
490
|
-
suffix: "Roku font family",
|
|
491
|
-
},
|
|
492
|
-
{
|
|
493
|
-
type: ZAPPIFEST_FIELDS.number_input,
|
|
494
|
-
suffix: "Roku font size",
|
|
495
|
-
},
|
|
496
|
-
{
|
|
497
|
-
type: ZAPPIFEST_FIELDS.number_input,
|
|
498
|
-
suffix: "Roku line height",
|
|
499
|
-
},
|
|
500
488
|
{
|
|
501
489
|
type: ZAPPIFEST_FIELDS.select,
|
|
502
490
|
suffix: "text transform",
|
|
@@ -424,12 +424,6 @@ const titleFields = [
|
|
|
424
424
|
key: "vizio_font_family",
|
|
425
425
|
initial_value: fontFamily,
|
|
426
426
|
},
|
|
427
|
-
{
|
|
428
|
-
type: "roku_font_selector",
|
|
429
|
-
label: "Roku TV Font Family",
|
|
430
|
-
key: "roku_font_family",
|
|
431
|
-
initial_value: fontFamily,
|
|
432
|
-
},
|
|
433
427
|
...generateFontConfiguration(),
|
|
434
428
|
// text transform
|
|
435
429
|
{
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applicaster/zapp-react-native-utils",
|
|
3
|
-
"version": "14.0.0-alpha.
|
|
3
|
+
"version": "14.0.0-alpha.6461844364",
|
|
4
4
|
"description": "Applicaster Zapp React Native utilities package",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
},
|
|
28
28
|
"homepage": "https://github.com/applicaster/quickbrick#readme",
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@applicaster/applicaster-types": "14.0.0-alpha.
|
|
30
|
+
"@applicaster/applicaster-types": "14.0.0-alpha.6461844364",
|
|
31
31
|
"buffer": "^5.2.1",
|
|
32
32
|
"camelize": "^1.0.0",
|
|
33
33
|
"dayjs": "^1.11.10",
|
package/playerUtils/index.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { isFilledArray } from "@applicaster/zapp-react-native-utils/arrayUtils";
|
|
|
5
5
|
import { isTV } from "@applicaster/zapp-react-native-utils/reactUtils";
|
|
6
6
|
|
|
7
7
|
import { getBoolFromConfigValue } from "../configurationUtils";
|
|
8
|
+
import { Dimensions } from "react-native";
|
|
8
9
|
|
|
9
10
|
export { getPlayerActionButtons } from "./getPlayerActionButtons";
|
|
10
11
|
|
|
@@ -97,3 +98,53 @@ export const isAudioItem = (item: Option<ZappEntry>) => {
|
|
|
97
98
|
export const isInlineTV = (screenData) => {
|
|
98
99
|
return isTV() && isFilledArray(screenData?.ui_components);
|
|
99
100
|
};
|
|
101
|
+
|
|
102
|
+
const isPercentage = (value: string | number): boolean => {
|
|
103
|
+
if (typeof value === "string") {
|
|
104
|
+
return value.includes("%");
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
return false;
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
const getPercentageOf = (percent: string, value: number) => {
|
|
111
|
+
const percentageValue = parseFloat(percent.replace("%", ""));
|
|
112
|
+
|
|
113
|
+
if (isNaN(percentageValue)) {
|
|
114
|
+
return value;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
return (value * percentageValue) / 100;
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
type DimensionsT = {
|
|
121
|
+
width: number | string;
|
|
122
|
+
height: number | string | undefined;
|
|
123
|
+
aspectRatio?: number;
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
export const getTabletWidth = (
|
|
127
|
+
tablet_landscape_sidebar_width,
|
|
128
|
+
dimensions: DimensionsT
|
|
129
|
+
) => {
|
|
130
|
+
const { width: SCREEN_WIDTH } = Dimensions.get("screen");
|
|
131
|
+
|
|
132
|
+
const { width } = dimensions;
|
|
133
|
+
let widthValue = Number(width);
|
|
134
|
+
|
|
135
|
+
if (isPercentage(width)) {
|
|
136
|
+
widthValue = getPercentageOf(width.toString(), SCREEN_WIDTH);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
const sidebarWidth = Number(tablet_landscape_sidebar_width?.replace("%", ""));
|
|
140
|
+
|
|
141
|
+
if (tablet_landscape_sidebar_width?.includes("%")) {
|
|
142
|
+
return widthValue * (1 - sidebarWidth / 100);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
if (Number.isNaN(sidebarWidth)) {
|
|
146
|
+
return widthValue * 0.65;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
return widthValue - sidebarWidth;
|
|
150
|
+
};
|
|
@@ -1,25 +1,27 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { renderHook } from "@testing-library/react-hooks";
|
|
4
|
+
import { act, waitFor } from "@testing-library/react-native";
|
|
4
5
|
import { Provider } from "react-redux";
|
|
5
6
|
import configureStore from "redux-mock-store";
|
|
7
|
+
import { useTrackedView } from "../useTrackedView";
|
|
6
8
|
|
|
7
9
|
const mockUpdateComponentsPositions = jest.fn();
|
|
8
10
|
|
|
9
11
|
jest.mock(
|
|
10
12
|
"@applicaster/zapp-react-native-ui-components/Contexts/ScreenTrackedViewPositionsContext",
|
|
11
13
|
() => ({
|
|
12
|
-
useScreenTrackedViewPositionsContext: jest.fn()
|
|
14
|
+
useScreenTrackedViewPositionsContext: jest.fn(() => ({
|
|
13
15
|
updateComponentsPositions: mockUpdateComponentsPositions,
|
|
14
16
|
value: {
|
|
15
17
|
"123": { componentId: "123", centerX: 0.4, centerY: 0.5 },
|
|
16
18
|
"124": { componentId: "124", centerX: 0.2, centerY: 0.3 },
|
|
17
19
|
},
|
|
18
|
-
}),
|
|
20
|
+
})),
|
|
19
21
|
})
|
|
20
22
|
);
|
|
21
23
|
|
|
22
|
-
jest.useFakeTimers(
|
|
24
|
+
jest.useFakeTimers();
|
|
23
25
|
|
|
24
26
|
jest.mock("@applicaster/zapp-react-native-utils/reactHooks/navigation");
|
|
25
27
|
|
|
@@ -32,10 +34,8 @@ const Wrapper = ({ children }: { children: React.ReactChild }) => (
|
|
|
32
34
|
<Provider store={store}>{children}</Provider>
|
|
33
35
|
);
|
|
34
36
|
|
|
35
|
-
const { useTrackedView } = require("../useTrackedView");
|
|
36
|
-
|
|
37
37
|
describe("useTrackCurrentAutoScrollingElement", () => {
|
|
38
|
-
it("should update position for selected component - onViewportEnter", () => {
|
|
38
|
+
it("should update position for selected component - onViewportEnter", async () => {
|
|
39
39
|
const { result } = renderHook(() => useTrackedView("123"), {
|
|
40
40
|
wrapper: Wrapper,
|
|
41
41
|
});
|
|
@@ -46,14 +46,13 @@ describe("useTrackCurrentAutoScrollingElement", () => {
|
|
|
46
46
|
rect: { left: 1, right: 1, top: 1, bottom: 1 },
|
|
47
47
|
};
|
|
48
48
|
|
|
49
|
-
act(
|
|
50
|
-
|
|
49
|
+
act(() => {
|
|
50
|
+
result.current.onPositionUpdated(mockRect);
|
|
51
51
|
});
|
|
52
52
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
expect(result.current.inViewPort).toBe(true);
|
|
53
|
+
await waitFor(() => {
|
|
54
|
+
expect(result.current.inViewPort).toBe(true);
|
|
55
|
+
});
|
|
57
56
|
|
|
58
57
|
expect(mockUpdateComponentsPositions).toHaveBeenCalledWith(
|
|
59
58
|
"123",
|