@applicaster/zapp-react-native-ui-components 16.0.0-rc.3 → 16.0.0-rc.30
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/Components/BackgroundImage/BackgroundImage.android.tv.tsx +28 -0
- package/Components/BackgroundImage/BackgroundImage.ios.tv.tsx +24 -0
- package/Components/BackgroundImage/BackgroundImage.tsx +42 -0
- package/Components/BackgroundImage/index.ts +1 -0
- package/Components/CellRendererResolver/index.ts +2 -2
- package/Components/ComponentResolver/__tests__/componentResolver.test.js +1 -1
- package/Components/FocusableGroup/FocusableTvOS.tsx +11 -7
- package/Components/GeneralContentScreen/GeneralContentScreenHookAdapter.tsx +39 -0
- package/Components/GeneralContentScreen/__tests__/GeneralContentScreenHookAdapter.test.tsx +64 -0
- package/Components/GeneralContentScreen/__tests__/HookContentFocusGroup.web.test.tsx +91 -0
- package/Components/GeneralContentScreen/hookAdapter/__tests__/networkService.test.ts +74 -0
- package/Components/GeneralContentScreen/hookAdapter/__tests__/runInBackground.test.ts +139 -0
- package/Components/GeneralContentScreen/hookAdapter/__tests__/validationHelper.test.ts +124 -0
- package/Components/GeneralContentScreen/hookAdapter/logger.ts +6 -0
- package/Components/GeneralContentScreen/hookAdapter/networkService.ts +53 -0
- package/Components/GeneralContentScreen/hookAdapter/runInBackground.ts +48 -0
- package/Components/GeneralContentScreen/hookAdapter/validationHelper.ts +72 -0
- package/Components/GeneralContentScreen/hookFocus/index.tsx +13 -0
- package/Components/GeneralContentScreen/hookFocus/index.web.tsx +69 -0
- package/Components/GeneralContentScreen/index.ts +2 -0
- package/Components/Layout/FullWidthRow.tsx +38 -0
- package/Components/Layout/TV/ScreenContainer.tsx +5 -0
- package/Components/Layout/TV/__tests__/__snapshots__/index.test.tsx.snap +0 -1
- package/Components/Layout/TV/index.tsx +3 -4
- package/Components/Layout/TV/index.web.tsx +2 -3
- package/Components/MasterCell/DefaultComponents/ActionButton.tsx +16 -5
- package/Components/MasterCell/DefaultComponents/ButtonContainerView/index.tsx +1 -1
- package/Components/MasterCell/dataAdapter.ts +15 -5
- package/Components/MasterCell/index.tsx +30 -5
- package/Components/MasterCell/utils/__tests__/resolveColor.test.js +169 -132
- package/Components/MasterCell/utils/__tests__/resolveColorForProp.test.js +92 -0
- package/Components/MasterCell/utils/index.ts +85 -46
- package/Components/PlayerContainer/PlayerContainer.tsx +14 -10
- package/Components/PlayerContainer/__tests__/PlayerContainer.test.tsx +284 -0
- package/Components/River/ComponentsMap/ComponentsMap.tsx +2 -2
- package/Components/River/__tests__/__snapshots__/componentsMap.test.js.snap +3 -15
- package/Components/Screen/TV/hooks/__tests__/useAfterPaint.test.ts +60 -0
- package/Components/Screen/TV/hooks/index.ts +2 -0
- package/Components/Screen/TV/hooks/useAfterPaint.ts +23 -0
- package/Components/Screen/TV/index.web.tsx +16 -7
- package/Components/Screen/index.tsx +8 -4
- package/Components/ScreenRevealManager/Overlay.tsx +34 -0
- package/Components/ScreenRevealManager/__tests__/Overlay.test.tsx +88 -0
- package/Components/ScreenRevealManager/withScreenRevealManager.tsx +8 -19
- package/Components/VideoLive/LiveImageManager.ts +56 -45
- package/Components/VideoLive/PlayerLiveImageComponent.tsx +4 -2
- package/Components/VideoModal/utils.ts +6 -1
- package/Components/ZappFrameworkComponents/BarView/BarView.tsx +12 -5
- package/Components/ZappFrameworkComponents/BarView/__tests__/BarView.test.tsx +2 -2
- package/Contexts/CachedDimensionsContext/__tests__/index.test.ts +154 -0
- package/Contexts/CachedDimensionsContext/index.ts +17 -2
- package/Helpers/ComponentCellSelectionHelper/index.js +0 -6
- package/Helpers/index.js +7 -40
- package/package.json +5 -5
- package/Components/Layout/TV/LayoutBackground.tsx +0 -31
- package/Components/Screen/utils.ts +0 -16
- package/Helpers/Analytics/index.js +0 -95
- /package/Components/MasterCell/DefaultComponents/ButtonContainerView/{index.tv.android.tsx → index.android.tv.tsx} +0 -0
|
@@ -2,7 +2,10 @@ import * as R from "ramda";
|
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
import { v4 as uuid } from "uuid";
|
|
4
4
|
|
|
5
|
+
import { isHorizontalList } from "@applicaster/zapp-react-native-utils/componentsUtils";
|
|
6
|
+
import { isVideoPreviewEnabled } from "@applicaster/zapp-react-native-ui-components/Components/MasterCell/utils";
|
|
5
7
|
import { useRoute } from "@applicaster/zapp-react-native-utils/reactHooks/navigation";
|
|
8
|
+
import { useTheme } from "@applicaster/zapp-react-native-utils/theme";
|
|
6
9
|
import { useScreenState } from "@applicaster/zapp-react-native-utils/screenState";
|
|
7
10
|
import { defaultComponents } from "./DefaultComponents";
|
|
8
11
|
import { defaultDataAdapter } from "./dataAdapter";
|
|
@@ -34,8 +37,8 @@ type MasterCellBuilderOptions = {
|
|
|
34
37
|
containerStyle: any;
|
|
35
38
|
cellOptions?: {
|
|
36
39
|
isRTL?: boolean;
|
|
37
|
-
generateId?: () => string;
|
|
38
40
|
skipButtons?: boolean;
|
|
41
|
+
component?: ZappComponent;
|
|
39
42
|
};
|
|
40
43
|
};
|
|
41
44
|
|
|
@@ -46,7 +49,7 @@ export function masterCellBuilder({
|
|
|
46
49
|
containerStyle = defaultContainerStyle,
|
|
47
50
|
cellOptions = {},
|
|
48
51
|
}: MasterCellBuilderOptions) {
|
|
49
|
-
const {
|
|
52
|
+
const { skipButtons = false, component } = cellOptions;
|
|
50
53
|
|
|
51
54
|
const componentsMap = R.merge(defaultComponents, components);
|
|
52
55
|
const { View } = componentsMap;
|
|
@@ -65,6 +68,7 @@ export function masterCellBuilder({
|
|
|
65
68
|
*/
|
|
66
69
|
function MasterCell({ item, state, ...otherProps }: Props) {
|
|
67
70
|
const { screenData } = useRoute();
|
|
71
|
+
const theme = useTheme();
|
|
68
72
|
|
|
69
73
|
const screenId =
|
|
70
74
|
screenData && "targetScreen" in screenData
|
|
@@ -85,14 +89,35 @@ export function masterCellBuilder({
|
|
|
85
89
|
elementsBuilder({
|
|
86
90
|
entry: item,
|
|
87
91
|
state: getEntryState(state, entryIsSelected),
|
|
92
|
+
allowDynamicColorsOutsideExtensions:
|
|
93
|
+
theme?.allow_dynamic_colors_outside_extensions,
|
|
88
94
|
}),
|
|
89
|
-
[
|
|
95
|
+
[
|
|
96
|
+
state,
|
|
97
|
+
item,
|
|
98
|
+
entryIsSelected,
|
|
99
|
+
theme?.allow_dynamic_colors_outside_extensions,
|
|
100
|
+
] // Assuming that item won't mutate
|
|
90
101
|
);
|
|
91
102
|
|
|
92
103
|
const wrapperRef = React.useRef(null);
|
|
93
104
|
|
|
94
|
-
const cellUUID = React.useMemo<string>(
|
|
95
|
-
|
|
105
|
+
const cellUUID = React.useMemo<string>(() => {
|
|
106
|
+
const isLiveImage = isVideoPreviewEnabled({
|
|
107
|
+
enable_video_preview: component?.rules?.enable_video_preview,
|
|
108
|
+
player_screen_id: component?.rules?.player_screen_id,
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
const isHL = isHorizontalList(component);
|
|
112
|
+
|
|
113
|
+
return isHL && isLiveImage
|
|
114
|
+
? `${component?.id}-${component?.styles?.cell_plugin_configuration_id}`
|
|
115
|
+
: uuid();
|
|
116
|
+
}, [
|
|
117
|
+
component?.id,
|
|
118
|
+
component?.styles?.cell_plugin_configuration_id,
|
|
119
|
+
component?.rules?.enable_video_preview,
|
|
120
|
+
component?.rules?.player_screen_id,
|
|
96
121
|
screenId,
|
|
97
122
|
item?.id,
|
|
98
123
|
]);
|
|
@@ -1,194 +1,231 @@
|
|
|
1
1
|
import { resolveColor } from "..";
|
|
2
|
-
import { masterCellLogger } from "../../logger";
|
|
3
|
-
|
|
4
|
-
const loggerSpy = jest
|
|
5
|
-
.spyOn(masterCellLogger, "warn")
|
|
6
|
-
.mockImplementation(() => {});
|
|
7
2
|
|
|
8
3
|
describe("resolveColor", () => {
|
|
9
4
|
const entry = {
|
|
10
5
|
extensions: {
|
|
11
6
|
color: "red",
|
|
12
7
|
green_color: "green",
|
|
8
|
+
float_alpha_color: "rgba(239,239,239,1.0)",
|
|
9
|
+
invalid_color: "not_a_color",
|
|
13
10
|
},
|
|
11
|
+
background_color: "#123456",
|
|
14
12
|
};
|
|
15
13
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
const style = {
|
|
22
|
-
color: "extensions.color",
|
|
23
|
-
};
|
|
14
|
+
describe("default behavior (resolves extensions paths via pathOr, passes through literals)", () => {
|
|
15
|
+
it("resolves color from extensions data mapping path", () => {
|
|
16
|
+
const style = {
|
|
17
|
+
color: "extensions.color",
|
|
18
|
+
};
|
|
24
19
|
|
|
25
|
-
|
|
26
|
-
|
|
20
|
+
expect(resolveColor(entry, style)).toEqual({
|
|
21
|
+
color: entry.extensions.color,
|
|
22
|
+
});
|
|
27
23
|
});
|
|
28
|
-
});
|
|
29
24
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
25
|
+
it("passes through non-extensions values as raw color strings", () => {
|
|
26
|
+
const style = {
|
|
27
|
+
color: "invalid_path",
|
|
28
|
+
};
|
|
34
29
|
|
|
35
|
-
|
|
36
|
-
|
|
30
|
+
expect(resolveColor(entry, style)).toEqual({
|
|
31
|
+
color: "invalid_path",
|
|
32
|
+
});
|
|
37
33
|
});
|
|
38
34
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
colorFromProp: "invalid_path",
|
|
44
|
-
configurationValue: "invalid_path",
|
|
45
|
-
},
|
|
46
|
-
})
|
|
47
|
-
);
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
it("resolves any style prop with containing color", () => {
|
|
51
|
-
const style = {
|
|
52
|
-
backgroundColor: "extensions.color",
|
|
53
|
-
width: "100%",
|
|
54
|
-
borderColor: "extensions.green_color",
|
|
55
|
-
};
|
|
35
|
+
it("passes through entry path keys outside extensions prefix as raw color strings", () => {
|
|
36
|
+
const style = {
|
|
37
|
+
color: "background_color",
|
|
38
|
+
};
|
|
56
39
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
width: "100%",
|
|
40
|
+
expect(resolveColor(entry, style)).toEqual({
|
|
41
|
+
color: "background_color",
|
|
42
|
+
});
|
|
61
43
|
});
|
|
62
|
-
});
|
|
63
44
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
45
|
+
it("resolves all color-related style props from extensions paths", () => {
|
|
46
|
+
const style = {
|
|
47
|
+
backgroundColor: "extensions.color",
|
|
48
|
+
width: "100%",
|
|
49
|
+
borderColor: "extensions.green_color",
|
|
50
|
+
};
|
|
68
51
|
|
|
69
|
-
|
|
70
|
-
|
|
52
|
+
expect(resolveColor(entry, style)).toEqual({
|
|
53
|
+
backgroundColor: "red",
|
|
54
|
+
borderColor: "green",
|
|
55
|
+
width: "100%",
|
|
56
|
+
});
|
|
57
|
+
});
|
|
71
58
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
59
|
+
it("passes through literal hex color values unchanged", () => {
|
|
60
|
+
const style = {
|
|
61
|
+
color: "#000000",
|
|
62
|
+
};
|
|
76
63
|
|
|
77
|
-
|
|
78
|
-
|
|
64
|
+
expect(resolveColor(entry, style)).toEqual(style);
|
|
65
|
+
});
|
|
79
66
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
67
|
+
it("passes through literal rgba color values unchanged", () => {
|
|
68
|
+
const style = {
|
|
69
|
+
color: "rgba(0,0,0,0)",
|
|
70
|
+
};
|
|
84
71
|
|
|
85
|
-
|
|
86
|
-
|
|
72
|
+
expect(resolveColor(entry, style)).toEqual(style);
|
|
73
|
+
});
|
|
87
74
|
|
|
88
|
-
|
|
89
|
-
|
|
75
|
+
it("passes through literal rgba values with float alpha unchanged", () => {
|
|
76
|
+
const style = {
|
|
77
|
+
color: "rgba(239,239,239,1.0)",
|
|
78
|
+
};
|
|
90
79
|
|
|
91
|
-
|
|
92
|
-
|
|
80
|
+
expect(resolveColor(entry, style)).toEqual(style);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it("passes through transparent as a literal color value", () => {
|
|
84
|
+
const style = {
|
|
85
|
+
color: "transparent",
|
|
86
|
+
};
|
|
93
87
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
test: 1,
|
|
97
|
-
};
|
|
88
|
+
expect(resolveColor(entry, style)).toEqual(style);
|
|
89
|
+
});
|
|
98
90
|
|
|
99
|
-
|
|
100
|
-
|
|
91
|
+
it("passes through named color values as literal colors", () => {
|
|
92
|
+
const style = {
|
|
93
|
+
color: "black",
|
|
94
|
+
};
|
|
101
95
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
color: "not.exist.path",
|
|
105
|
-
};
|
|
96
|
+
expect(resolveColor(entry, style)).toEqual(style);
|
|
97
|
+
});
|
|
106
98
|
|
|
107
|
-
|
|
108
|
-
|
|
99
|
+
it("returns style unchanged when style is undefined", () => {
|
|
100
|
+
expect(resolveColor(entry, undefined)).toBeUndefined();
|
|
109
101
|
});
|
|
110
|
-
});
|
|
111
102
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
};
|
|
103
|
+
it("returns style unchanged when style is null", () => {
|
|
104
|
+
expect(resolveColor(entry, null)).toBeNull();
|
|
105
|
+
});
|
|
116
106
|
|
|
117
|
-
|
|
118
|
-
|
|
107
|
+
it("returns style unchanged when it has no color-related props", () => {
|
|
108
|
+
const style = {
|
|
109
|
+
test: 1,
|
|
110
|
+
};
|
|
119
111
|
|
|
120
|
-
|
|
121
|
-
beforeEach(() => {
|
|
122
|
-
// Clear memoization cache before each test
|
|
123
|
-
resolveColor.clear && resolveColor.clear();
|
|
112
|
+
expect(resolveColor(entry, style)).toEqual(style);
|
|
124
113
|
});
|
|
125
114
|
|
|
126
|
-
it("
|
|
127
|
-
const style = {
|
|
115
|
+
it("returns null when extensions path is missing from entry", () => {
|
|
116
|
+
const style = {
|
|
117
|
+
color: "extensions.missing.path",
|
|
118
|
+
};
|
|
128
119
|
|
|
129
|
-
|
|
130
|
-
|
|
120
|
+
expect(resolveColor(entry, style)).toEqual({
|
|
121
|
+
color: null,
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
it("returns resolved extensions path value without validating color", () => {
|
|
126
|
+
const style = {
|
|
127
|
+
color: "extensions.invalid_color",
|
|
128
|
+
};
|
|
131
129
|
|
|
132
|
-
expect(
|
|
130
|
+
expect(resolveColor(entry, style)).toEqual({
|
|
131
|
+
color: "not_a_color",
|
|
132
|
+
});
|
|
133
133
|
});
|
|
134
134
|
|
|
135
|
-
it("
|
|
136
|
-
const
|
|
137
|
-
|
|
138
|
-
color: "red",
|
|
139
|
-
green_color: "green",
|
|
140
|
-
},
|
|
135
|
+
it("passes through empty string color values unchanged", () => {
|
|
136
|
+
const style = {
|
|
137
|
+
color: "",
|
|
141
138
|
};
|
|
142
139
|
|
|
143
|
-
|
|
144
|
-
|
|
140
|
+
expect(resolveColor(entry, style)).toEqual({
|
|
141
|
+
color: "",
|
|
142
|
+
});
|
|
143
|
+
});
|
|
145
144
|
|
|
146
|
-
|
|
147
|
-
const
|
|
145
|
+
it("resolves rgba color values with float alpha from extensions path", () => {
|
|
146
|
+
const style = {
|
|
147
|
+
color: "extensions.float_alpha_color",
|
|
148
|
+
};
|
|
148
149
|
|
|
149
|
-
expect(
|
|
150
|
+
expect(resolveColor(entry, style)).toEqual({
|
|
151
|
+
color: "rgba(239,239,239,1.0)",
|
|
152
|
+
});
|
|
150
153
|
});
|
|
154
|
+
});
|
|
151
155
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
const style = {
|
|
156
|
+
describe("when allowDynamicColorsOutsideExtensions is enabled (resolves via resolveColorForProp with validation)", () => {
|
|
157
|
+
it("resolves entry paths outside the extensions prefix", () => {
|
|
158
|
+
const style = {
|
|
159
|
+
color: "background_color",
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
expect(resolveColor(entry, style, true)).toEqual({
|
|
163
|
+
color: "#123456",
|
|
164
|
+
});
|
|
165
|
+
});
|
|
155
166
|
|
|
156
|
-
|
|
157
|
-
const
|
|
167
|
+
it("resolves extensions paths through resolveColorForProp", () => {
|
|
168
|
+
const style = {
|
|
169
|
+
color: "extensions.color",
|
|
170
|
+
};
|
|
158
171
|
|
|
159
|
-
expect(
|
|
172
|
+
expect(resolveColor(entry, style, true)).toEqual({
|
|
173
|
+
color: "red",
|
|
174
|
+
});
|
|
160
175
|
});
|
|
161
176
|
|
|
162
|
-
it("
|
|
163
|
-
const
|
|
164
|
-
|
|
165
|
-
color: "red",
|
|
166
|
-
green_color: "green",
|
|
167
|
-
},
|
|
177
|
+
it("returns null for invalid entry paths that cannot be resolved", () => {
|
|
178
|
+
const style = {
|
|
179
|
+
color: "invalid_path",
|
|
168
180
|
};
|
|
169
181
|
|
|
170
|
-
|
|
182
|
+
expect(resolveColor(entry, style, true)).toEqual({
|
|
183
|
+
color: null,
|
|
184
|
+
});
|
|
185
|
+
});
|
|
171
186
|
|
|
172
|
-
|
|
187
|
+
it("returns null when extensions path cannot be resolved to a valid color", () => {
|
|
188
|
+
const style = {
|
|
189
|
+
color: "extensions.missing.path",
|
|
190
|
+
};
|
|
173
191
|
|
|
174
|
-
|
|
175
|
-
|
|
192
|
+
expect(resolveColor(entry, style, true)).toEqual({
|
|
193
|
+
color: null,
|
|
194
|
+
});
|
|
195
|
+
});
|
|
176
196
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
197
|
+
it("passes through literal color values unchanged", () => {
|
|
198
|
+
const style = {
|
|
199
|
+
color: "#000000",
|
|
200
|
+
backgroundColor: "rgba(239,239,239,1.0)",
|
|
201
|
+
borderColor: "transparent",
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
expect(resolveColor(entry, style, true)).toEqual(style);
|
|
180
205
|
});
|
|
181
206
|
|
|
182
|
-
it("
|
|
183
|
-
const
|
|
184
|
-
|
|
207
|
+
it("passes through empty string color values unchanged", () => {
|
|
208
|
+
const style = {
|
|
209
|
+
color: "",
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
expect(resolveColor(entry, style, true)).toEqual({
|
|
213
|
+
color: "",
|
|
214
|
+
});
|
|
215
|
+
});
|
|
185
216
|
|
|
186
|
-
|
|
187
|
-
const
|
|
217
|
+
it("resolves multiple color-related style props from entry paths", () => {
|
|
218
|
+
const style = {
|
|
219
|
+
backgroundColor: "background_color",
|
|
220
|
+
borderColor: "extensions.green_color",
|
|
221
|
+
width: "100%",
|
|
222
|
+
};
|
|
188
223
|
|
|
189
|
-
expect(
|
|
190
|
-
|
|
191
|
-
|
|
224
|
+
expect(resolveColor(entry, style, true)).toEqual({
|
|
225
|
+
backgroundColor: "#123456",
|
|
226
|
+
borderColor: "green",
|
|
227
|
+
width: "100%",
|
|
228
|
+
});
|
|
192
229
|
});
|
|
193
230
|
});
|
|
194
231
|
});
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { resolveColorForProp } from "..";
|
|
2
|
+
|
|
3
|
+
jest.mock("../../logger", () => ({
|
|
4
|
+
masterCellLogger: {
|
|
5
|
+
warn: jest.fn(),
|
|
6
|
+
},
|
|
7
|
+
}));
|
|
8
|
+
|
|
9
|
+
import { masterCellLogger } from "../../logger";
|
|
10
|
+
|
|
11
|
+
describe("resolveColorForProp", () => {
|
|
12
|
+
const entry = {
|
|
13
|
+
extensions: {
|
|
14
|
+
color: "red",
|
|
15
|
+
green_color: "green",
|
|
16
|
+
float_alpha_color: "rgba(239,239,239,1.0)",
|
|
17
|
+
},
|
|
18
|
+
background_color: "#123456",
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
beforeEach(() => {
|
|
22
|
+
jest.clearAllMocks();
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it("returns undefined when colorFromProp is undefined", () => {
|
|
26
|
+
expect(resolveColorForProp(entry, undefined)).toBeUndefined();
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it("returns undefined when colorFromProp is empty string", () => {
|
|
30
|
+
expect(resolveColorForProp(entry, "")).toBeUndefined();
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it("resolves color from extensions data mapping path", () => {
|
|
34
|
+
expect(resolveColorForProp(entry, "extensions.color")).toBe("red");
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it("resolves color from nested entry path", () => {
|
|
38
|
+
expect(resolveColorForProp(entry, "background_color")).toBe("#123456");
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it("returns valid hex color values", () => {
|
|
42
|
+
expect(resolveColorForProp(entry, "#000000")).toBe("#000000");
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it("returns valid rgba color values", () => {
|
|
46
|
+
expect(resolveColorForProp(entry, "rgba(0,0,0,0)")).toBe("rgba(0,0,0,0)");
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it("returns valid named color values", () => {
|
|
50
|
+
expect(resolveColorForProp(entry, "transparent")).toBe("transparent");
|
|
51
|
+
expect(resolveColorForProp(entry, "black")).toBe("black");
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it("returns undefined for invalid non-entry color values", () => {
|
|
55
|
+
expect(resolveColorForProp(entry, "invalid_path")).toBeUndefined();
|
|
56
|
+
|
|
57
|
+
expect(masterCellLogger.warn).toHaveBeenCalledWith({
|
|
58
|
+
message: "Cannot resolve property invalid_path from the entry.",
|
|
59
|
+
data: {
|
|
60
|
+
configurationValue: "invalid_path",
|
|
61
|
+
colorFromProp: "invalid_path",
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it("returns undefined when extensions path is missing", () => {
|
|
67
|
+
expect(
|
|
68
|
+
resolveColorForProp(entry, "extensions.missing.path")
|
|
69
|
+
).toBeUndefined();
|
|
70
|
+
|
|
71
|
+
expect(masterCellLogger.warn).toHaveBeenCalledWith({
|
|
72
|
+
message:
|
|
73
|
+
"Cannot resolve property extensions.missing.path from the entry.",
|
|
74
|
+
data: {
|
|
75
|
+
configurationValue: "extensions.missing.path",
|
|
76
|
+
colorFromProp: "extensions.missing.path",
|
|
77
|
+
},
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
it("resolves rgba color values with float alpha from entry path", () => {
|
|
82
|
+
expect(resolveColorForProp(entry, "extensions.float_alpha_color")).toBe(
|
|
83
|
+
"rgba(239,239,239,1.0)"
|
|
84
|
+
);
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
it("returns valid rgba color values with float alpha", () => {
|
|
88
|
+
expect(resolveColorForProp(entry, "rgba(239,239,239,1.0)")).toBe(
|
|
89
|
+
"rgba(239,239,239,1.0)"
|
|
90
|
+
);
|
|
91
|
+
});
|
|
92
|
+
});
|