@applicaster/zapp-react-native-utils 12.0.0-rc.25 → 12.0.0-rc.26
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/__tests__/analyticsManager.test.js +75 -73
- package/appUtils/keyCodes/__tests__/__snapshots__/keyCodes.test.js.snap +1 -1
- package/appUtils/keyCodes/__tests__/keyCodes.test.js +80 -85
- package/appUtils/keyCodes/keys.web.js +1 -0
- package/cellUtils/__tests__/cellUtils.test.ts +59 -0
- package/cellUtils/__tests__/fixtures.ts +13 -0
- package/cellUtils/index.ts +29 -0
- package/functionUtils/__tests__/__snapshots__/functionUtils.test.js.snap +2 -2
- package/functionUtils/__tests__/functionUtils.test.js +244 -248
- package/localizationUtils/__tests__/localizationUtils.test.ts +17 -13
- package/manifestUtils/defaultManifestConfigurations/player.js +8 -0
- package/package.json +3 -2
- package/playerUtils/configurationGenerator.ts +8 -0
- package/reactHooks/layout/__tests__/index.test.js +22 -30
- package/reactHooks/layout/useDimensions/helpers/__tests__/getInitialDimensions.native.test.js +11 -16
- package/reactHooks/layout/useDimensions/helpers/__tests__/getInitialDimensions.test.js +12 -14
- package/screenState/index.ts +8 -0
|
@@ -1,18 +1,18 @@
|
|
|
1
|
+
import * as ReactNative from "react-native";
|
|
2
|
+
|
|
1
3
|
const mock_postEvent = jest.fn();
|
|
2
4
|
const mock_setPlugins = jest.fn();
|
|
3
5
|
const mock_postTimedEvent = jest.fn();
|
|
4
6
|
const mock_endTimedEvent = jest.fn();
|
|
5
7
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
},
|
|
15
|
-
}));
|
|
8
|
+
const AnalyticsBridge = {
|
|
9
|
+
postEvent: mock_postEvent,
|
|
10
|
+
setPlugins: mock_setPlugins,
|
|
11
|
+
postTimedEvent: mock_postTimedEvent,
|
|
12
|
+
endTimedEvent: mock_endTimedEvent,
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
ReactNative.NativeModules.AnalyticsBridge = AnalyticsBridge;
|
|
16
16
|
|
|
17
17
|
const eventName = "event";
|
|
18
18
|
const payload = {};
|
|
@@ -26,90 +26,92 @@ function clearAllMocks() {
|
|
|
26
26
|
mock_endTimedEvent.mockClear();
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
describe("
|
|
30
|
-
|
|
29
|
+
describe("AnalyticsManager", () => {
|
|
30
|
+
describe("isValidAnalyticsData", () => {
|
|
31
|
+
beforeEach(clearAllMocks);
|
|
31
32
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
33
|
+
it("returns false if eventName is not a string", () => {
|
|
34
|
+
expect(analyticsManager.isValidAnalyticsData(42)).toBe(false);
|
|
35
|
+
expect(analyticsManager.isValidAnalyticsData({})).toBe(false);
|
|
36
|
+
expect(analyticsManager.isValidAnalyticsData([])).toBe(false);
|
|
37
|
+
expect(analyticsManager.isValidAnalyticsData(() => ({}))).toBe(false);
|
|
38
|
+
});
|
|
38
39
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
40
|
+
it("returns false if payload is not an object", () => {
|
|
41
|
+
expect(analyticsManager.isValidAnalyticsData(eventName, "string")).toBe(
|
|
42
|
+
false
|
|
43
|
+
);
|
|
43
44
|
|
|
44
|
-
|
|
45
|
+
expect(analyticsManager.isValidAnalyticsData(eventName, 42)).toBe(false);
|
|
45
46
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
expect(analyticsManager.isValidAnalyticsData(eventName, () => ({}))).toBe(
|
|
48
|
+
false
|
|
49
|
+
);
|
|
50
|
+
});
|
|
50
51
|
|
|
51
|
-
|
|
52
|
-
|
|
52
|
+
it("returns true if eventName is a string and payload is null or an object", () => {
|
|
53
|
+
expect(analyticsManager.isValidAnalyticsData(eventName)).toBe(true);
|
|
53
54
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
55
|
+
expect(analyticsManager.isValidAnalyticsData(eventName, payload)).toBe(
|
|
56
|
+
true
|
|
57
|
+
);
|
|
58
|
+
});
|
|
57
59
|
});
|
|
58
|
-
});
|
|
59
60
|
|
|
60
|
-
describe("postAnalyticEvent", () => {
|
|
61
|
-
|
|
61
|
+
describe("postAnalyticEvent", () => {
|
|
62
|
+
beforeEach(clearAllMocks);
|
|
62
63
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
64
|
+
it("calls the postEvent method of the analytic bridge", () => {
|
|
65
|
+
analyticsManager.postAnalyticEvent(eventName, payload);
|
|
66
|
+
expect(mock_postEvent).toHaveBeenCalledWith(eventName, payload);
|
|
67
|
+
});
|
|
67
68
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
69
|
+
it("skips the event if it is not valid", () => {
|
|
70
|
+
analyticsManager.postAnalyticEvent(42);
|
|
71
|
+
expect(mock_postTimedEvent).not.toHaveBeenCalled();
|
|
72
|
+
});
|
|
71
73
|
});
|
|
72
|
-
});
|
|
73
74
|
|
|
74
|
-
describe("providePlugins", () => {
|
|
75
|
-
|
|
75
|
+
describe("providePlugins", () => {
|
|
76
|
+
beforeEach(clearAllMocks);
|
|
76
77
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
78
|
+
it("calls the setPlugins method of the analytic bridge", () => {
|
|
79
|
+
const plugins = [];
|
|
80
|
+
const plugin_configurations = {};
|
|
81
|
+
const callback = jest.fn();
|
|
81
82
|
|
|
82
|
-
|
|
83
|
+
analyticsManager.providePlugins(plugins, plugin_configurations, callback);
|
|
83
84
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
85
|
+
expect(mock_setPlugins).toHaveBeenCalledWith(
|
|
86
|
+
plugins,
|
|
87
|
+
plugin_configurations,
|
|
88
|
+
callback
|
|
89
|
+
);
|
|
90
|
+
});
|
|
89
91
|
});
|
|
90
|
-
});
|
|
91
92
|
|
|
92
|
-
describe("startAnalyticsTimedEvent", () => {
|
|
93
|
-
|
|
93
|
+
describe("startAnalyticsTimedEvent", () => {
|
|
94
|
+
beforeEach(clearAllMocks);
|
|
94
95
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
96
|
+
it("skips the event if it is not valid", () => {
|
|
97
|
+
analyticsManager.startAnalyticsTimedEvent(42);
|
|
98
|
+
expect(mock_postTimedEvent).not.toHaveBeenCalled();
|
|
99
|
+
});
|
|
98
100
|
});
|
|
99
|
-
});
|
|
100
101
|
|
|
101
|
-
describe("endAnalyticsTimedEvent", () => {
|
|
102
|
-
|
|
102
|
+
describe("endAnalyticsTimedEvent", () => {
|
|
103
|
+
beforeEach(clearAllMocks);
|
|
103
104
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
105
|
+
it("emits a time_on_screen event and adds duration to payload", () => {
|
|
106
|
+
analyticsManager.endAnalyticsTimedEvent(eventName, payload);
|
|
107
|
+
const newEventName = "time_on_screen";
|
|
108
|
+
payload.duration = "N/A";
|
|
109
|
+
expect(mock_postEvent).toHaveBeenCalledWith(newEventName, payload);
|
|
110
|
+
});
|
|
110
111
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
112
|
+
it("skips the event if it is not valid", () => {
|
|
113
|
+
analyticsManager.endAnalyticsTimedEvent(42);
|
|
114
|
+
expect(mock_postEvent).not.toHaveBeenCalled();
|
|
115
|
+
});
|
|
114
116
|
});
|
|
115
117
|
});
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
const { Platform } = require("react-native");
|
|
2
|
+
|
|
3
|
+
Platform.OS = "web";
|
|
4
|
+
|
|
1
5
|
import { directionHelper } from "../../directionHelper";
|
|
2
6
|
|
|
3
7
|
const globalTizen = {
|
|
@@ -6,105 +10,96 @@ const globalTizen = {
|
|
|
6
10
|
},
|
|
7
11
|
};
|
|
8
12
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
describe("keyCode", () => {
|
|
14
|
-
const { keyCode } = require("../index");
|
|
15
|
-
const { KEYS } = require("../keys.web");
|
|
16
|
-
|
|
17
|
-
it("returns an object for a given key event", () => {
|
|
18
|
-
expect(keyCode(KEYS.Enter)).toMatchSnapshot();
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
it("has a matcher method for a single key", () => {
|
|
22
|
-
expect(keyCode(KEYS.Enter).matches("Enter")).toBeTruthy();
|
|
23
|
-
expect(keyCode(KEYS.Enter).matches(KEYS.Enter)).toBeTruthy();
|
|
24
|
-
expect(keyCode(KEYS.Back).matches("Enter")).toBeFalsy();
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
it("has matcher for multiple keys", () => {
|
|
28
|
-
expect(
|
|
29
|
-
keyCode(KEYS.Enter).matchesAny("Enter", "Back", "ArrowUp")
|
|
30
|
-
).toBeTruthy();
|
|
13
|
+
describe("keyCodes", () => {
|
|
14
|
+
describe("keyCode", () => {
|
|
15
|
+
const { keyCode } = require("..");
|
|
16
|
+
const { KEYS } = require("../keys.web");
|
|
31
17
|
|
|
32
|
-
|
|
33
|
-
keyCode(KEYS.Enter).
|
|
34
|
-
)
|
|
35
|
-
});
|
|
18
|
+
it("returns an object for a given key event", () => {
|
|
19
|
+
expect(keyCode(KEYS.Enter)).toMatchSnapshot();
|
|
20
|
+
});
|
|
36
21
|
|
|
37
|
-
|
|
38
|
-
|
|
22
|
+
it("has a matcher method for a single key", () => {
|
|
23
|
+
expect(keyCode(KEYS.Enter).matches("Enter")).toBeTruthy();
|
|
24
|
+
expect(keyCode(KEYS.Enter).matches(KEYS.Enter)).toBeTruthy();
|
|
25
|
+
expect(keyCode(KEYS.Back).matches("Enter")).toBeFalsy();
|
|
26
|
+
});
|
|
39
27
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
28
|
+
it("has matcher for multiple keys", () => {
|
|
29
|
+
expect(
|
|
30
|
+
keyCode(KEYS.Enter).matchesAny("Enter", "Back", "ArrowUp")
|
|
31
|
+
).toBeTruthy();
|
|
44
32
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
33
|
+
expect(
|
|
34
|
+
keyCode(KEYS.Enter).matchesAny("Back", "ArrowUp", "ArrowDown")
|
|
35
|
+
).toBeFalsy();
|
|
48
36
|
});
|
|
49
|
-
});
|
|
50
|
-
});
|
|
51
37
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
return { Platform: { OS: "samsung_tv" } };
|
|
55
|
-
});
|
|
38
|
+
it("returns the direction if it matches an arrow key", () => {
|
|
39
|
+
expect(keyCode(KEYS.Enter).direction()).toBe(null);
|
|
56
40
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
41
|
+
expect(keyCode(KEYS.ArrowDown).direction()).toEqual(
|
|
42
|
+
directionHelper(KEYS.ArrowDown)
|
|
43
|
+
);
|
|
44
|
+
});
|
|
61
45
|
|
|
62
|
-
|
|
63
|
-
|
|
46
|
+
describe("in web env", () => {
|
|
47
|
+
it("uses the proper keyCode for the environment", () => {
|
|
48
|
+
expect(keyCode({ keyCode: 13 }).matches(KEYS.Enter)).toBeTruthy();
|
|
49
|
+
});
|
|
50
|
+
});
|
|
64
51
|
});
|
|
65
52
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
53
|
+
describe("in Tizen Env", () => {
|
|
54
|
+
beforeEach(() => {
|
|
55
|
+
jest.resetModules();
|
|
56
|
+
global.tizen = globalTizen;
|
|
57
|
+
});
|
|
69
58
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
"MediaPlayPause",
|
|
74
|
-
"MediaPause",
|
|
75
|
-
"MediaFastForward",
|
|
76
|
-
"MediaRewind",
|
|
77
|
-
"MediaStop",
|
|
78
|
-
"Exit",
|
|
79
|
-
"0",
|
|
80
|
-
"1",
|
|
81
|
-
"2",
|
|
82
|
-
"3",
|
|
83
|
-
"4",
|
|
84
|
-
"5",
|
|
85
|
-
"6",
|
|
86
|
-
"7",
|
|
87
|
-
"8",
|
|
88
|
-
"9",
|
|
89
|
-
]);
|
|
90
|
-
|
|
91
|
-
expect(keyCode({ keyCode: 10009 }).matches(KEYS.Back)).toBeTruthy();
|
|
92
|
-
});
|
|
93
|
-
});
|
|
59
|
+
afterEach(() => {
|
|
60
|
+
global.tizen = undefined;
|
|
61
|
+
});
|
|
94
62
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
63
|
+
it("uses the proper keyCode for the environment", () => {
|
|
64
|
+
Platform.OS = "samsung_tv";
|
|
65
|
+
const { keyCode } = require("../");
|
|
66
|
+
const { KEYS } = require("../keys.web");
|
|
67
|
+
|
|
68
|
+
expect(globalTizen.tvinputdevice.registerKeyBatch).toHaveBeenCalledWith([
|
|
69
|
+
"MediaPlay",
|
|
70
|
+
"MediaPlayPause",
|
|
71
|
+
"MediaPause",
|
|
72
|
+
"MediaFastForward",
|
|
73
|
+
"MediaRewind",
|
|
74
|
+
"MediaStop",
|
|
75
|
+
"Exit",
|
|
76
|
+
"0",
|
|
77
|
+
"1",
|
|
78
|
+
"2",
|
|
79
|
+
"3",
|
|
80
|
+
"4",
|
|
81
|
+
"5",
|
|
82
|
+
"6",
|
|
83
|
+
"7",
|
|
84
|
+
"8",
|
|
85
|
+
"9",
|
|
86
|
+
]);
|
|
87
|
+
|
|
88
|
+
expect(keyCode({ keyCode: 10009 }).matches(KEYS.Back)).toBeTruthy();
|
|
89
|
+
});
|
|
98
90
|
});
|
|
99
91
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
92
|
+
describe("in WebOS Env", () => {
|
|
93
|
+
beforeEach(() => {
|
|
94
|
+
jest.resetModules();
|
|
95
|
+
});
|
|
103
96
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
97
|
+
it("uses the proper keyCode for the environment", () => {
|
|
98
|
+
Platform.OS = "lg_tv";
|
|
99
|
+
const { keyCode } = require("..");
|
|
100
|
+
const { KEYS } = require("../keys.web");
|
|
101
|
+
// Back is reserved on LG
|
|
102
|
+
expect(keyCode({ keyCode: 417 }).matches(KEYS.Forward)).toBeTruthy();
|
|
103
|
+
});
|
|
109
104
|
});
|
|
110
105
|
});
|
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
castAndFallbackColor,
|
|
15
15
|
compact,
|
|
16
16
|
getValue,
|
|
17
|
+
getColorFromData,
|
|
17
18
|
} from "../";
|
|
18
19
|
|
|
19
20
|
import {
|
|
@@ -23,6 +24,7 @@ import {
|
|
|
23
24
|
EMPTY,
|
|
24
25
|
FALLBACK,
|
|
25
26
|
TRANSFORM,
|
|
27
|
+
defaultColor,
|
|
26
28
|
} from "./fixtures";
|
|
27
29
|
|
|
28
30
|
describe("getKeyForLabel", () => {
|
|
@@ -388,3 +390,60 @@ describe("getValue", () => {
|
|
|
388
390
|
expect(getValue({ value })(value)).toBeNull();
|
|
389
391
|
});
|
|
390
392
|
});
|
|
393
|
+
|
|
394
|
+
describe("getColorFromData", () => {
|
|
395
|
+
it("should return value directly if valid color", () => {
|
|
396
|
+
const result = getColorFromData({
|
|
397
|
+
data: entry,
|
|
398
|
+
key: "background_color",
|
|
399
|
+
getValue: getValue(componentStyle),
|
|
400
|
+
defaultColor,
|
|
401
|
+
});
|
|
402
|
+
|
|
403
|
+
expect(result).toBe("#123456");
|
|
404
|
+
});
|
|
405
|
+
|
|
406
|
+
it("should return valid rgba color name", () => {
|
|
407
|
+
const result = getColorFromData({
|
|
408
|
+
data: entry,
|
|
409
|
+
key: "component_background_color",
|
|
410
|
+
getValue: getValue(componentStyle),
|
|
411
|
+
defaultColor,
|
|
412
|
+
});
|
|
413
|
+
|
|
414
|
+
expect(result).toBe("rgba(255, 255, 255, 0)");
|
|
415
|
+
});
|
|
416
|
+
|
|
417
|
+
it("should return path value if path value is set and is valid color", () => {
|
|
418
|
+
const result = getColorFromData({
|
|
419
|
+
data: entry,
|
|
420
|
+
key: VAL.colorKeyPath,
|
|
421
|
+
getValue: getValue(componentStyle),
|
|
422
|
+
defaultColor,
|
|
423
|
+
});
|
|
424
|
+
|
|
425
|
+
expect(result).toBe("#123456");
|
|
426
|
+
});
|
|
427
|
+
|
|
428
|
+
it("should return defaultColor if key value and path value are invalid", () => {
|
|
429
|
+
const result = getColorFromData({
|
|
430
|
+
data: entry,
|
|
431
|
+
key: VAL.invalidColorKey,
|
|
432
|
+
getValue: getValue(componentStyle),
|
|
433
|
+
defaultColor,
|
|
434
|
+
});
|
|
435
|
+
|
|
436
|
+
expect(result).toBe(defaultColor);
|
|
437
|
+
});
|
|
438
|
+
|
|
439
|
+
it("should return defaultColor if path does not exist", () => {
|
|
440
|
+
const result = getColorFromData({
|
|
441
|
+
data: entry,
|
|
442
|
+
key: VAL.invalidColorKeyPath,
|
|
443
|
+
getValue: getValue(componentStyle),
|
|
444
|
+
defaultColor,
|
|
445
|
+
});
|
|
446
|
+
|
|
447
|
+
expect(result).toBe(defaultColor);
|
|
448
|
+
});
|
|
449
|
+
});
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
/* eslint-disable max-len */
|
|
2
2
|
|
|
3
|
+
export const defaultColor = "#ffffff";
|
|
4
|
+
|
|
3
5
|
export const entry = {
|
|
4
6
|
type: {
|
|
5
7
|
value: "video",
|
|
@@ -26,7 +28,9 @@ export const entry = {
|
|
|
26
28
|
type: "video/mp4",
|
|
27
29
|
src: "https://wino-feed.s3.amazonaws.com/movieFeed/Ford+v+Ferrari.mp4",
|
|
28
30
|
},
|
|
31
|
+
background_color: "#123456",
|
|
29
32
|
extensions: {
|
|
33
|
+
background_color: "#123456",
|
|
30
34
|
free: false,
|
|
31
35
|
duration: 9000,
|
|
32
36
|
section: "New Releases",
|
|
@@ -46,7 +50,11 @@ export const componentStyle = {
|
|
|
46
50
|
horizontal_list_cell_width: "400",
|
|
47
51
|
cell_plugin_configuration_id: "267bd05a-08bd-4675-bdd3-9b73899773f0",
|
|
48
52
|
horizontal_list_scaled_switch: false,
|
|
53
|
+
background_color: "#123456",
|
|
49
54
|
component_background_color: "rgba(255, 255, 255, 0)",
|
|
55
|
+
background_color_1: "extensions.background_color",
|
|
56
|
+
background_color_2: "invalidColorKey",
|
|
57
|
+
background_color_3: "extensions.invalidColorKeyPath",
|
|
50
58
|
component_padding_left: "",
|
|
51
59
|
horizontal_list_next_offset: 20,
|
|
52
60
|
component_margin_bottom: "",
|
|
@@ -93,6 +101,11 @@ export const VAL = {
|
|
|
93
101
|
upper: "STRING",
|
|
94
102
|
width: 400,
|
|
95
103
|
height: 225,
|
|
104
|
+
colorKey: "background_color",
|
|
105
|
+
colorKeyRgba: "component_background_color",
|
|
106
|
+
colorKeyPath: "background_color_1",
|
|
107
|
+
invalidColorKey: "background_color_2",
|
|
108
|
+
invalidColorKeyPath: "background_color_3",
|
|
96
109
|
};
|
|
97
110
|
|
|
98
111
|
export const TRANSFORM = {
|
package/cellUtils/index.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as R from "ramda";
|
|
2
2
|
import dayjs from "dayjs";
|
|
3
|
+
import validateColor from "validate-color";
|
|
3
4
|
|
|
4
5
|
import { toNumberWithDefault, toNumberWithDefaultZero } from "../numberUtils";
|
|
5
6
|
import { transformColorCode as fixColorHexCode } from "../transform";
|
|
@@ -443,3 +444,31 @@ export const toResizeMode = (
|
|
|
443
444
|
resizeMode: "contain",
|
|
444
445
|
};
|
|
445
446
|
};
|
|
447
|
+
|
|
448
|
+
type GetColorFromData = {
|
|
449
|
+
data: Record<string, any>;
|
|
450
|
+
key: string;
|
|
451
|
+
getValue: Function;
|
|
452
|
+
defaultColor: string;
|
|
453
|
+
};
|
|
454
|
+
|
|
455
|
+
export const getColorFromData = ({
|
|
456
|
+
data,
|
|
457
|
+
key,
|
|
458
|
+
getValue,
|
|
459
|
+
defaultColor,
|
|
460
|
+
}: GetColorFromData): string => {
|
|
461
|
+
const value = getValue(key);
|
|
462
|
+
|
|
463
|
+
if (validateColor(value)) {
|
|
464
|
+
return value;
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
const pathValue = R.path(value.split("."), data);
|
|
468
|
+
|
|
469
|
+
if (pathValue && validateColor(pathValue)) {
|
|
470
|
+
return pathValue;
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
return defaultColor;
|
|
474
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
|
-
exports[`subscriber can be invoked without args 1`] = `
|
|
3
|
+
exports[`functionUtils subscriber can be invoked without args 1`] = `
|
|
4
4
|
Object {
|
|
5
5
|
"handlers": Object {},
|
|
6
6
|
"invokeHandler": [Function],
|
|
@@ -9,7 +9,7 @@ Object {
|
|
|
9
9
|
}
|
|
10
10
|
`;
|
|
11
11
|
|
|
12
|
-
exports[`subscriber returns the original object with additional methods 1`] = `
|
|
12
|
+
exports[`functionUtils subscriber returns the original object with additional methods 1`] = `
|
|
13
13
|
Object {
|
|
14
14
|
"foo": "bar",
|
|
15
15
|
"handlers": Object {},
|