@applicaster/zapp-react-native-utils 14.0.0-alpha.8387612031 → 14.0.0-alpha.9567513212
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/arrayUtils/__tests__/isFilledArray.test.ts +1 -1
- package/arrayUtils/index.ts +2 -7
- package/configurationUtils/__tests__/configurationUtils.test.js +31 -0
- package/configurationUtils/index.ts +34 -63
- package/package.json +2 -2
- package/playerUtils/index.ts +51 -2
- package/reactHooks/feed/useBatchLoading.ts +2 -2
- package/utils/index.ts +1 -9
- package/arrayUtils/__tests__/isEmptyArray.test.ts +0 -63
- package/audioPlayerUtils/__tests__/getArtworkImage.test.ts +0 -144
- package/audioPlayerUtils/__tests__/getBackgroundImage.test.ts +0 -72
- package/audioPlayerUtils/__tests__/getImageFromEntry.test.ts +0 -110
- package/audioPlayerUtils/assets/index.ts +0 -2
- package/audioPlayerUtils/index.ts +0 -138
- package/conf/player/__tests__/selectors.test.ts +0 -34
- package/conf/player/selectors.ts +0 -10
- package/configurationUtils/__tests__/getMediaItems.test.ts +0 -65
- package/configurationUtils/__tests__/imageSrcFromMediaItem.test.ts +0 -34
- package/playerUtils/__tests__/getPlayerActionButtons.test.ts +0 -54
- package/playerUtils/getPlayerActionButtons.ts +0 -17
package/arrayUtils/index.ts
CHANGED
|
@@ -99,17 +99,12 @@ export const makeListOf = (value: unknown, size: number): number[] => {
|
|
|
99
99
|
|
|
100
100
|
/** Checks if a value is a non-empty array */
|
|
101
101
|
export function isFilledArray(value: unknown): boolean {
|
|
102
|
-
return
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
/** Checks if a value is a empty array */
|
|
106
|
-
export function isEmptyArray(value: unknown): boolean {
|
|
107
|
-
return Array.isArray(value) && value.length === 0;
|
|
102
|
+
return R.is(Array, value) && R.length(value) > 0;
|
|
108
103
|
}
|
|
109
104
|
|
|
110
105
|
// get random item from the list
|
|
111
106
|
export const sample = (xs: unknown[]): unknown => {
|
|
112
|
-
invariant(
|
|
107
|
+
invariant(R.is(Array, xs), `input value is not a array: ${xs}`);
|
|
113
108
|
invariant(isFilledArray(xs), `input array is empty: ${xs}`);
|
|
114
109
|
|
|
115
110
|
const index = Math.floor(Math.random() * xs.length);
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
import * as R from "ramda";
|
|
1
2
|
import {
|
|
2
3
|
populateConfigurationValues,
|
|
4
|
+
imageSrcFromMediaItem,
|
|
3
5
|
getBoolFromConfigValue,
|
|
4
6
|
remapUpdatedKeys,
|
|
5
7
|
} from "../";
|
|
8
|
+
import { entry } from "./testEntry";
|
|
6
9
|
|
|
7
10
|
describe("getBoolFromConfigValue", () => {
|
|
8
11
|
it('returns true if value is "true" string', () => {
|
|
@@ -54,6 +57,34 @@ describe("getBoolFromConfigValue", () => {
|
|
|
54
57
|
});
|
|
55
58
|
});
|
|
56
59
|
|
|
60
|
+
describe("imageSrcFromMediaItem", () => {
|
|
61
|
+
describe("returns the src value of first media_item", () => {
|
|
62
|
+
it("when the matching key is found and the src is not empty", () => {
|
|
63
|
+
const result = imageSrcFromMediaItem(entry, ["logo_thumbnail"]);
|
|
64
|
+
|
|
65
|
+
expect(result).toEqual(entry.media_group[1].media_item[0].src);
|
|
66
|
+
expect(result).not.toEqual("");
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it("returns a media item with the 'image_base' key as a fallback", () => {
|
|
71
|
+
const result = imageSrcFromMediaItem(entry, ["does_not_exist"]);
|
|
72
|
+
const fallback = entry.media_group[0].media_item[0];
|
|
73
|
+
expect(result).toEqual(fallback.src);
|
|
74
|
+
expect(fallback.key).toBe("image_base");
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it("returns undefined if the key was found but the source was empty", () => {
|
|
78
|
+
const badEntry = R.set(
|
|
79
|
+
R.lensPath(["media_group", 0, "media_item", 0, "src"]),
|
|
80
|
+
"",
|
|
81
|
+
entry
|
|
82
|
+
);
|
|
83
|
+
|
|
84
|
+
expect(imageSrcFromMediaItem(badEntry, ["image_base"])).toBeUndefined();
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
|
|
57
88
|
describe("populateConfigurationValues", () => {
|
|
58
89
|
it("transforms and returns the valid values", () => {
|
|
59
90
|
const fields = [
|
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
/// <reference types="@applicaster/applicaster-types" />
|
|
2
2
|
import * as R from "ramda";
|
|
3
3
|
import { Platform } from "react-native";
|
|
4
|
-
import {
|
|
5
|
-
isFilledArray,
|
|
6
|
-
isEmptyArray,
|
|
7
|
-
} from "@applicaster/zapp-react-native-utils/arrayUtils";
|
|
8
|
-
import { isEmpty } from "@applicaster/zapp-react-native-utils/utils";
|
|
9
|
-
|
|
10
4
|
import { applyTransform } from "../transform";
|
|
11
5
|
import { ManifestField } from "../types";
|
|
12
6
|
import { isNilOrEmpty } from "../reactUtils/helpers";
|
|
@@ -128,77 +122,54 @@ export function flattenFields(
|
|
|
128
122
|
}
|
|
129
123
|
|
|
130
124
|
/**
|
|
131
|
-
* Retrieves
|
|
132
|
-
*
|
|
133
|
-
*
|
|
134
|
-
* @
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
if (isEmptyArray(mediaGroup)) {
|
|
140
|
-
return undefined;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
const mediaItems = mediaGroup
|
|
144
|
-
.filter((group) => ["image", "thumbnail"].includes(group.type))
|
|
145
|
-
.flatMap((group) =>
|
|
146
|
-
Array.isArray(group.media_item) ? group.media_item : [group.media_item]
|
|
147
|
-
);
|
|
148
|
-
|
|
149
|
-
if (isFilledArray(mediaItems)) {
|
|
150
|
-
return mediaItems;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
return undefined;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
/**
|
|
157
|
-
* Retrieves the "src" value from a media item in the entry's media group,
|
|
158
|
-
* based on a provided key, with fallback logic.
|
|
159
|
-
*
|
|
160
|
-
* Fallback order:
|
|
161
|
-
* 1. Attempts to find a media item with the specified key (or "image_base" if none provided).
|
|
162
|
-
* 2. If not found, attempts to find a media item with the key "image_base".
|
|
163
|
-
* 3. If still not found, falls back to the first available media item.
|
|
164
|
-
*
|
|
165
|
-
* Special handling: If the resolved item's "src" is an empty string, returns undefined,
|
|
166
|
-
* since empty URIs are invalid in some platforms (e.g., React Native).
|
|
167
|
-
*
|
|
168
|
-
* @param {ZappEntry} entry - The entry object containing a media group.
|
|
169
|
-
* @param {string[] | unknown} arg - A single-element array containing the key to look up, or any unknown value.
|
|
170
|
-
* @returns {?string} The "src" URI from the matched media item, or undefined if not found or empty.
|
|
125
|
+
* Retrieves the value of the "src" in the first media_item
|
|
126
|
+
* that has the matching key provided in args.
|
|
127
|
+
* Fallbacks: "image_base" key, or first media_item that has any "src"
|
|
128
|
+
* @param {Object} entry Single entry from a feed
|
|
129
|
+
* @param {Array} arg Array with a single element - the key of the media item
|
|
130
|
+
* from which the "src" should be retrieved
|
|
131
|
+
* @returns {?String} Value of "src", usually a URI
|
|
171
132
|
*/
|
|
172
133
|
export function imageSrcFromMediaItem(
|
|
173
134
|
entry: ZappEntry,
|
|
174
135
|
arg: string[] | unknown
|
|
175
|
-
)
|
|
136
|
+
) {
|
|
176
137
|
const args: unknown = R.unless(Array.isArray, Array)(arg || []);
|
|
177
138
|
const imageKey: string = args?.[0] || "image_base"; // always a single key in this function
|
|
139
|
+
const mediaGroup = R.path<ZappMediaGroup[]>(["media_group"], entry);
|
|
178
140
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
if (!mediaItems) {
|
|
141
|
+
if (!mediaGroup) {
|
|
182
142
|
return undefined;
|
|
183
143
|
}
|
|
184
144
|
|
|
185
|
-
|
|
186
|
-
|
|
145
|
+
const hasTypeImageOrThumbnail = R.either(
|
|
146
|
+
R.propEq("type", "image"),
|
|
147
|
+
R.propEq("type", "thumbnail")
|
|
148
|
+
);
|
|
149
|
+
|
|
150
|
+
const pickMediaItemProp = R.prop<ZappMediaItem>("media_item");
|
|
187
151
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
152
|
+
const mediaItems = R.compose(
|
|
153
|
+
R.flatten,
|
|
154
|
+
R.map(pickMediaItemProp),
|
|
155
|
+
R.filter(hasTypeImageOrThumbnail)
|
|
156
|
+
)(mediaGroup);
|
|
192
157
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
foundItem = mediaItems[0];
|
|
158
|
+
if (!mediaItems) {
|
|
159
|
+
return undefined;
|
|
196
160
|
}
|
|
197
161
|
|
|
198
|
-
const src =
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
162
|
+
const src = R.compose(
|
|
163
|
+
R.prop("src"),
|
|
164
|
+
R.defaultTo(R.head(mediaItems)),
|
|
165
|
+
R.when(R.isNil, () => R.find(R.propEq("key", "image_base"), mediaItems)),
|
|
166
|
+
R.find(R.propEq("key", imageKey))
|
|
167
|
+
)(mediaItems);
|
|
168
|
+
|
|
169
|
+
// Special case for react native - uri cannot be an empty string (yellow warning).
|
|
170
|
+
// R.isEmpty is tailored specifically for checks like these,
|
|
171
|
+
// it returns false for undefined values.
|
|
172
|
+
return R.isEmpty(src) ? undefined : src;
|
|
202
173
|
}
|
|
203
174
|
|
|
204
175
|
/**
|
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.9567513212",
|
|
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.9567513212",
|
|
31
31
|
"buffer": "^5.2.1",
|
|
32
32
|
"camelize": "^1.0.0",
|
|
33
33
|
"dayjs": "^1.11.10",
|
package/playerUtils/index.ts
CHANGED
|
@@ -5,8 +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
|
-
|
|
9
|
-
export { getPlayerActionButtons } from "./getPlayerActionButtons";
|
|
8
|
+
import { Dimensions } from "react-native";
|
|
10
9
|
|
|
11
10
|
/**
|
|
12
11
|
* Gets duration value from player manager, and from extensions
|
|
@@ -97,3 +96,53 @@ export const isAudioItem = (item: Option<ZappEntry>) => {
|
|
|
97
96
|
export const isInlineTV = (screenData) => {
|
|
98
97
|
return isTV() && isFilledArray(screenData?.ui_components);
|
|
99
98
|
};
|
|
99
|
+
|
|
100
|
+
const isPercentage = (value: string | number): boolean => {
|
|
101
|
+
if (typeof value === "string") {
|
|
102
|
+
return value.includes("%");
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
return false;
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
const getPercentageOf = (percent: string, value: number) => {
|
|
109
|
+
const percentageValue = parseFloat(percent.replace("%", ""));
|
|
110
|
+
|
|
111
|
+
if (isNaN(percentageValue)) {
|
|
112
|
+
return value;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
return (value * percentageValue) / 100;
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
type DimensionsT = {
|
|
119
|
+
width: number | string;
|
|
120
|
+
height: number | string | undefined;
|
|
121
|
+
aspectRatio?: number;
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
export const getTabletWidth = (
|
|
125
|
+
tablet_landscape_sidebar_width,
|
|
126
|
+
dimensions: DimensionsT
|
|
127
|
+
) => {
|
|
128
|
+
const { width: SCREEN_WIDTH } = Dimensions.get("screen");
|
|
129
|
+
|
|
130
|
+
const { width } = dimensions;
|
|
131
|
+
let widthValue = Number(width);
|
|
132
|
+
|
|
133
|
+
if (isPercentage(width)) {
|
|
134
|
+
widthValue = getPercentageOf(width.toString(), SCREEN_WIDTH);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const sidebarWidth = Number(tablet_landscape_sidebar_width?.replace("%", ""));
|
|
138
|
+
|
|
139
|
+
if (tablet_landscape_sidebar_width?.includes("%")) {
|
|
140
|
+
return widthValue * (1 - sidebarWidth / 100);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
if (Number.isNaN(sidebarWidth)) {
|
|
144
|
+
return widthValue * 0.65;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
return widthValue - sidebarWidth;
|
|
148
|
+
};
|
|
@@ -144,11 +144,11 @@ export const useBatchLoading = (
|
|
|
144
144
|
}
|
|
145
145
|
}
|
|
146
146
|
});
|
|
147
|
-
}, [feedUrls
|
|
147
|
+
}, [feedUrls]);
|
|
148
148
|
|
|
149
149
|
React.useEffect(() => {
|
|
150
150
|
runBatchLoading();
|
|
151
|
-
}, [
|
|
151
|
+
}, []);
|
|
152
152
|
|
|
153
153
|
React.useEffect(() => {
|
|
154
154
|
// check if all feeds are ready and set hasEverBeenReady to true
|
package/utils/index.ts
CHANGED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { isEmptyArray } from "..";
|
|
2
|
-
|
|
3
|
-
describe("isEmptyArray", () => {
|
|
4
|
-
it("non-empty array is not empty", () => {
|
|
5
|
-
const value = [1, 2, 3];
|
|
6
|
-
|
|
7
|
-
expect(isEmptyArray(value)).toBe(false);
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
it("empty array is empty", () => {
|
|
11
|
-
const value = [];
|
|
12
|
-
|
|
13
|
-
expect(isEmptyArray(value)).toBe(true);
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
it("number is not array", () => {
|
|
17
|
-
const value = 123;
|
|
18
|
-
|
|
19
|
-
expect(isEmptyArray(value)).toBe(false);
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
it("string is not array", () => {
|
|
23
|
-
const value = "vfnjdk";
|
|
24
|
-
|
|
25
|
-
expect(isEmptyArray(value)).toBe(false);
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
it("empty string is not array", () => {
|
|
29
|
-
const value = "";
|
|
30
|
-
|
|
31
|
-
expect(isEmptyArray(value)).toBe(false);
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
it("NaN is not array", () => {
|
|
35
|
-
const value = NaN;
|
|
36
|
-
|
|
37
|
-
expect(isEmptyArray(value)).toBe(false);
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
it("object is not array", () => {
|
|
41
|
-
const value = { test: 1 };
|
|
42
|
-
|
|
43
|
-
expect(isEmptyArray(value)).toBe(false);
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
it("empty object is not array", () => {
|
|
47
|
-
const value = {};
|
|
48
|
-
|
|
49
|
-
expect(isEmptyArray(value)).toBe(false);
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
it("undefined is not array", () => {
|
|
53
|
-
const value = undefined;
|
|
54
|
-
|
|
55
|
-
expect(isEmptyArray(value)).toBe(false);
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
it("null is not array", () => {
|
|
59
|
-
const value = null;
|
|
60
|
-
|
|
61
|
-
expect(isEmptyArray(value)).toBe(false);
|
|
62
|
-
});
|
|
63
|
-
});
|
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
import { getArtworkImage } from "..";
|
|
2
|
-
import { DEFAULT_IMAGE } from "../assets";
|
|
3
|
-
|
|
4
|
-
describe("getArtworkImage", () => {
|
|
5
|
-
const entryWithImage = {
|
|
6
|
-
media_group: [
|
|
7
|
-
{
|
|
8
|
-
type: "image",
|
|
9
|
-
media_item: [
|
|
10
|
-
{ key: "artwork_key", src: "image_from_entry" },
|
|
11
|
-
{ key: "other_key", src: "other_image" },
|
|
12
|
-
],
|
|
13
|
-
},
|
|
14
|
-
],
|
|
15
|
-
extensions: {
|
|
16
|
-
artwork_key: "artwork_key",
|
|
17
|
-
},
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
const entryWithoutImage = {
|
|
21
|
-
media_group: [
|
|
22
|
-
{
|
|
23
|
-
type: "image",
|
|
24
|
-
media_item: [{ key: "other_key", src: "other_image" }],
|
|
25
|
-
},
|
|
26
|
-
],
|
|
27
|
-
extensions: {
|
|
28
|
-
artwork_key: "artwork_key",
|
|
29
|
-
},
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
const pluginConfigWithImage = {
|
|
33
|
-
artwork_key: "plugin_artwork_key",
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
it("returns image from entry extensions key", () => {
|
|
37
|
-
const result = getArtworkImage({
|
|
38
|
-
key: "artwork_key",
|
|
39
|
-
entry: entryWithImage,
|
|
40
|
-
plugin_configuration: {},
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
expect(result).toBe("image_from_entry");
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
it("returns image from plugin configuration key if not in entry", () => {
|
|
47
|
-
const entryNoMatch = {
|
|
48
|
-
...entryWithoutImage,
|
|
49
|
-
extensions: { artwork_key: "not_found_key" },
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
const pluginConfig = {
|
|
53
|
-
artwork_key: "plugin_artwork_key",
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
const entryWithPluginImage = {
|
|
57
|
-
...entryNoMatch,
|
|
58
|
-
media_group: [
|
|
59
|
-
{
|
|
60
|
-
type: "image",
|
|
61
|
-
media_item: [{ key: "plugin_artwork_key", src: "image_from_plugin" }],
|
|
62
|
-
},
|
|
63
|
-
],
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
const result = getArtworkImage({
|
|
67
|
-
key: "artwork_key",
|
|
68
|
-
entry: entryWithPluginImage,
|
|
69
|
-
plugin_configuration: pluginConfig,
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
expect(result).toBe("image_from_plugin");
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
it("returns DEFAULT_IMAGE if neither entry nor plugin configuration has image", () => {
|
|
76
|
-
const entryNoImage = {
|
|
77
|
-
media_group: [
|
|
78
|
-
{
|
|
79
|
-
type: "image",
|
|
80
|
-
media_item: [{ key: "other_key", src: "other_image" }],
|
|
81
|
-
},
|
|
82
|
-
],
|
|
83
|
-
extensions: { artwork_key: "not_found_key" },
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
const pluginConfig = { artwork_key: "not_found_key" };
|
|
87
|
-
|
|
88
|
-
const result = getArtworkImage({
|
|
89
|
-
key: "artwork_key",
|
|
90
|
-
entry: entryNoImage,
|
|
91
|
-
plugin_configuration: pluginConfig,
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
expect(result).toBe(DEFAULT_IMAGE);
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
it("handles undefined key gracefully", () => {
|
|
98
|
-
const result = getArtworkImage({
|
|
99
|
-
key: undefined,
|
|
100
|
-
entry: entryWithImage,
|
|
101
|
-
plugin_configuration: pluginConfigWithImage,
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
expect(result).toBe(DEFAULT_IMAGE);
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
it("handles missing entry or plugin_configuration gracefully", () => {
|
|
108
|
-
const result = getArtworkImage({
|
|
109
|
-
key: "artwork_key",
|
|
110
|
-
entry: undefined,
|
|
111
|
-
plugin_configuration: undefined,
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
expect(result).toBe(DEFAULT_IMAGE);
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
it("handles empty media_group", () => {
|
|
118
|
-
const entryEmptyMedia = {
|
|
119
|
-
media_group: [],
|
|
120
|
-
extensions: { artwork_key: "artwork_key" },
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
const result = getArtworkImage({
|
|
124
|
-
key: "artwork_key",
|
|
125
|
-
entry: entryEmptyMedia,
|
|
126
|
-
plugin_configuration: pluginConfigWithImage,
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
expect(result).toBe(DEFAULT_IMAGE);
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
it("handles missing extensions/config keys", () => {
|
|
133
|
-
const entryNoExt = { media_group: [], extensions: {} };
|
|
134
|
-
const pluginConfig = {};
|
|
135
|
-
|
|
136
|
-
const result = getArtworkImage({
|
|
137
|
-
key: "artwork_key",
|
|
138
|
-
entry: entryNoExt,
|
|
139
|
-
plugin_configuration: pluginConfig,
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
expect(result).toBe(DEFAULT_IMAGE);
|
|
143
|
-
});
|
|
144
|
-
});
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { getBackgroundImage } from "..";
|
|
2
|
-
import { DEFAULT_IMAGE } from "../assets";
|
|
3
|
-
|
|
4
|
-
describe("getBackgroundImage", () => {
|
|
5
|
-
const entryBase = {
|
|
6
|
-
media_group: [
|
|
7
|
-
{
|
|
8
|
-
media_item: [
|
|
9
|
-
{ key: "image_key_1", src: "image_src_1" },
|
|
10
|
-
{ key: "image_key_2", src: "image_src_2" },
|
|
11
|
-
],
|
|
12
|
-
type: "image",
|
|
13
|
-
},
|
|
14
|
-
],
|
|
15
|
-
extensions: {},
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
const pluginConfigBase = {};
|
|
19
|
-
|
|
20
|
-
it("returns image from entry.extensions.image_key if present", () => {
|
|
21
|
-
const entry = {
|
|
22
|
-
...entryBase,
|
|
23
|
-
extensions: { image_key: "image_key_2" },
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
const result = getBackgroundImage({
|
|
27
|
-
entry,
|
|
28
|
-
plugin_configuration: pluginConfigBase,
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
expect(result).toBe("image_src_2");
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
it("returns audio_player_background_image from entry.extensions if present and no image_key image", () => {
|
|
35
|
-
const entry = {
|
|
36
|
-
...entryBase,
|
|
37
|
-
extensions: { audio_player_background_image: "audio_img_ext" },
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
const result = getBackgroundImage({
|
|
41
|
-
entry,
|
|
42
|
-
plugin_configuration: pluginConfigBase,
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
expect(result).toBe("audio_img_ext");
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
it("returns image from plugin_configuration.audio_player_image_key if present and not found in entry.extensions", () => {
|
|
49
|
-
const entry = { ...entryBase };
|
|
50
|
-
const plugin_configuration = { audio_player_image_key: "image_key_1" };
|
|
51
|
-
const result = getBackgroundImage({ entry, plugin_configuration });
|
|
52
|
-
expect(result).toBe("image_src_1");
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
it("returns audio_player_background_image from plugin_configuration if present and not found in entry/extensions", () => {
|
|
56
|
-
const entry = { ...entryBase };
|
|
57
|
-
|
|
58
|
-
const plugin_configuration = {
|
|
59
|
-
audio_player_background_image: "audio_img_conf",
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
const result = getBackgroundImage({ entry, plugin_configuration });
|
|
63
|
-
expect(result).toBe("audio_img_conf");
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
it("returns DEFAULT_IMAGE if nothing is found", () => {
|
|
67
|
-
const entry = { media_group: [], extensions: {} };
|
|
68
|
-
const plugin_configuration = {};
|
|
69
|
-
const result = getBackgroundImage({ entry, plugin_configuration });
|
|
70
|
-
expect(result).toBe(DEFAULT_IMAGE);
|
|
71
|
-
});
|
|
72
|
-
});
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
import { getImageFromEntry } from "..";
|
|
2
|
-
|
|
3
|
-
const entry = {
|
|
4
|
-
media_group: [
|
|
5
|
-
{
|
|
6
|
-
media_item: [
|
|
7
|
-
{
|
|
8
|
-
key: "image_base_key",
|
|
9
|
-
src: "image_base_src",
|
|
10
|
-
},
|
|
11
|
-
{
|
|
12
|
-
key: "thumb_1",
|
|
13
|
-
src: null,
|
|
14
|
-
},
|
|
15
|
-
{
|
|
16
|
-
key: "thumb_2",
|
|
17
|
-
src: null,
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
key: "thumb_3",
|
|
21
|
-
src: null,
|
|
22
|
-
},
|
|
23
|
-
],
|
|
24
|
-
type: "image",
|
|
25
|
-
},
|
|
26
|
-
],
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
describe("getImageFromEntry", () => {
|
|
30
|
-
it("returns the src value for existing key", () => {
|
|
31
|
-
const result = getImageFromEntry({
|
|
32
|
-
entry,
|
|
33
|
-
imageKey: "image_base_key",
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
expect(result).toEqual("image_base_src");
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
it("returns undefined for non-existing key", () => {
|
|
40
|
-
const result = getImageFromEntry({
|
|
41
|
-
entry,
|
|
42
|
-
imageKey: "non_existing_key",
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
expect(result).toBeUndefined();
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
it("returns undefined for undefined key", () => {
|
|
49
|
-
const result = getImageFromEntry({
|
|
50
|
-
entry,
|
|
51
|
-
imageKey: undefined,
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
expect(result).toBeUndefined();
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
it("returns undefined for non string src", () => {
|
|
58
|
-
const entryWithNonStringSrc = {
|
|
59
|
-
media_group: [
|
|
60
|
-
{
|
|
61
|
-
media_item: [
|
|
62
|
-
{
|
|
63
|
-
key: "image_base_key",
|
|
64
|
-
src: 123,
|
|
65
|
-
},
|
|
66
|
-
{
|
|
67
|
-
key: "thumb_1",
|
|
68
|
-
src: null,
|
|
69
|
-
},
|
|
70
|
-
],
|
|
71
|
-
type: "image",
|
|
72
|
-
},
|
|
73
|
-
],
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
const result = getImageFromEntry({
|
|
77
|
-
entry: entryWithNonStringSrc,
|
|
78
|
-
imageKey: "image_base_key",
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
expect(result).toBeUndefined();
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
it("returns undefined for empty src", () => {
|
|
85
|
-
const entryWithEmptySrc = {
|
|
86
|
-
media_group: [
|
|
87
|
-
{
|
|
88
|
-
media_item: [
|
|
89
|
-
{
|
|
90
|
-
key: "image_base_key",
|
|
91
|
-
src: "",
|
|
92
|
-
},
|
|
93
|
-
{
|
|
94
|
-
key: "thumb_1",
|
|
95
|
-
src: null,
|
|
96
|
-
},
|
|
97
|
-
],
|
|
98
|
-
type: "image",
|
|
99
|
-
},
|
|
100
|
-
],
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
const result = getImageFromEntry({
|
|
104
|
-
entry: entryWithEmptySrc,
|
|
105
|
-
imageKey: "image_base_key",
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
expect(result).toBeUndefined();
|
|
109
|
-
});
|
|
110
|
-
});
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
export const DEFAULT_IMAGE =
|
|
2
|
-
"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAABwgAAAP0CAYAAAC+jGj3AAAxj0lEQVR4AezdIWyd59nH4af9piKXbKAOGXJQpShGJTYacXisSUOxIo1FQZNmBWyaFCXSVBCltHLQpMpGIzYasVFJjUpiVJKgEhuN9Nv9tk7bKI59nnOOfY7/1yW9Ou2aej7PW/bTfT8f3Lp164cGAAAAAAAARPiwAQAAAAAAADEEQgAAAAAAAAgiEAIAAAAAAEAQgRAAAAAAAACCCIQAAAAAAAAQRCAEAAAAAACAIAIhAAAAA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TkzaqpaWlNkmLi4ttVK9fv26zrud3nPTZ9vy8nv8mAAAA5plACAAAROmJWDXxd/v27TYpq6urbVTzEAh7QlvPWZyl4mDPdOY8nC0AAMAkCYQAAECU3hg0qUBYP6dngvD4+LjNupcvX7ZR1VlM6mzX19dbj6OjowYAAJBEIAQAAKIcHh62HhWfesLe2x48eNB69P7el6k3tG1sbLRx1btZW1trPQRCAAAgjUAIAABEqTWYvWtGHz9+3MZRIaz3zr15CIS9v2NNEI4bCXvfTcVBdxACAABpBEIAACDO/v5+61Fxb3Nzs/W4c+dOu3fvXutRQXMeptzGiW11Nnfv3m096p30htdvvvmmAQAApBEIAQCAOAcHB61XrbH88ssvL7xutCYPa63oX//619arN2hehe3t7darzmmUScJ6B/UueleLlr29vQYAAJDmg1u3bv3QAAAAwjx79mxYbTmOiksVxN413VdhsO4trHg17t2Ff/zjH7vWol6F+q5fffVVG0d9162trWFl6bu+d7231dXV4WzrnHvVe7t//34DAABIIxACAACRKjJVJJyEWqtZsaliVgWrWnc5bhQ8tbu7254+fdrmySTi66nTtaV1tnWmdbbjRMFfevLkiQlCAAAgkkAIAADEmmTImpZ5mh48VRGvVn/OsjrTOlsAAIBE7iAEAABi1RrLWVbrS+ctDpaa+hvnLsLL8OjRowYAAJBKIAQAAGLVHXezGrIqDL548aLNq/rdZzVunnVvJAAAQAqBEAAAiDarIasm3OruvXlVv3vd8Tdr5j28AgAATIJACAAARKuQ9fDhw5mKhM+fP78WE241oVnfZVbUO653Pc/hFQAAYBL+75NPPvl7AwAACFbBqGLWH/7wh/bRRx+1q1T3Iv7rX/9q18W33347fC4vL7erVO/4L3/5S/vuu+8aAABAOoEQAADgf77//vv29ddft88++6wtLCy0q1Bx8Dquv6z4Wq4qEtbkYMVB9w4CAAD8SCAEAAD4SUXCg4ODtrq6eqmRsKbbPv/887azs9Ouq4qE9T0//fTTS53SPF0ranIQAADgZx/cunXrhwYAAMAbFQfv3bvX1tfX27TVVNujR49m6g7EaVpcXGzPnj0bPq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ACAEUEIAAAAAAAAI4IQAAAAAAAARgQhAAAAAAAAjAhCAAAAAAAAGBGEAAAAAAAAMCIIAQAAAAAAYEQQAgAAAAAAwIggBAAAAAAAgBFBCAAAAAAAACOCEAAAAAAAAEYEIQAAAAAAAIwIQgAAAAAAABgRhAAAAAAAADAiCAEAAAAAAGBEEAIAAAAAAMCIIAQAAAAAAIARQQgAAAAAAAAjghAAAAAAAABGBCEAAAAAAACMCEIAAAAAAAAYEYQAAAAAAAAwIggBAAAAAABgRBACAAAAAADASOotf98aH400AAAAAElFTkSuQmCC";
|
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
import { isNotEmptyString } from "@applicaster/zapp-react-native-utils/stringUtils";
|
|
2
|
-
import { getMediaItems } from "@applicaster/zapp-react-native-utils/configurationUtils";
|
|
3
|
-
|
|
4
|
-
import { DEFAULT_IMAGE } from "./assets";
|
|
5
|
-
|
|
6
|
-
export function getImageFromEntry({
|
|
7
|
-
entry,
|
|
8
|
-
imageKey,
|
|
9
|
-
}: {
|
|
10
|
-
entry: ZappEntry;
|
|
11
|
-
imageKey: Option<string>;
|
|
12
|
-
}): Option<string> {
|
|
13
|
-
const mediaItems = getMediaItems(entry);
|
|
14
|
-
|
|
15
|
-
if (!mediaItems) {
|
|
16
|
-
return undefined;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
// Find the media item with the matching key
|
|
20
|
-
const found = mediaItems.find((item) => item.key === imageKey);
|
|
21
|
-
const src = found?.src;
|
|
22
|
-
|
|
23
|
-
// Special case for react native - uri cannot be an empty string (yellow warning).
|
|
24
|
-
return isNotEmptyString(src) ? src : undefined;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const getPropertyFromExtensions = (
|
|
28
|
-
key: string,
|
|
29
|
-
entry: ZappEntry
|
|
30
|
-
): Option<string> => entry?.extensions?.[key];
|
|
31
|
-
|
|
32
|
-
const getPropertyFromConfiguration = (
|
|
33
|
-
key: string,
|
|
34
|
-
plugin_configuration: Record<string, any>
|
|
35
|
-
) => plugin_configuration?.[key];
|
|
36
|
-
|
|
37
|
-
type GetBackgroundImageParams = {
|
|
38
|
-
entry: ZappEntry;
|
|
39
|
-
plugin_configuration: Record<string, any>;
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
export const getBackgroundImage = ({
|
|
43
|
-
entry,
|
|
44
|
-
plugin_configuration,
|
|
45
|
-
}: GetBackgroundImageParams): string => {
|
|
46
|
-
// 1) image_key from extensions
|
|
47
|
-
const imageKeyFromExtensions = getPropertyFromExtensions("image_key", entry);
|
|
48
|
-
|
|
49
|
-
const imageFromExtensions = getImageFromEntry({
|
|
50
|
-
entry,
|
|
51
|
-
imageKey: imageKeyFromExtensions,
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
if (imageFromExtensions) {
|
|
55
|
-
return imageFromExtensions;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
// 2) audio_player_background_image from extensions(KAN case)
|
|
59
|
-
const audioPlayerBackgroundImageFromExtensions = getPropertyFromExtensions(
|
|
60
|
-
"audio_player_background_image",
|
|
61
|
-
entry
|
|
62
|
-
);
|
|
63
|
-
|
|
64
|
-
if (isNotEmptyString(audioPlayerBackgroundImageFromExtensions)) {
|
|
65
|
-
return audioPlayerBackgroundImageFromExtensions;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
// 3) image_key from configuration
|
|
69
|
-
const imageKeyFromConfiguration = getPropertyFromConfiguration(
|
|
70
|
-
"audio_player_image_key",
|
|
71
|
-
plugin_configuration
|
|
72
|
-
);
|
|
73
|
-
|
|
74
|
-
const imageFromConfiguration = getImageFromEntry({
|
|
75
|
-
entry,
|
|
76
|
-
imageKey: imageKeyFromConfiguration,
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
if (imageFromConfiguration) {
|
|
80
|
-
return imageFromConfiguration;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
// 4) audio_player_background_image from configuration
|
|
84
|
-
const audioPlayerBackgroundImageFromConfiguration =
|
|
85
|
-
getPropertyFromConfiguration(
|
|
86
|
-
"audio_player_background_image",
|
|
87
|
-
plugin_configuration
|
|
88
|
-
);
|
|
89
|
-
|
|
90
|
-
if (isNotEmptyString(audioPlayerBackgroundImageFromConfiguration)) {
|
|
91
|
-
return audioPlayerBackgroundImageFromConfiguration;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
// default image
|
|
95
|
-
return DEFAULT_IMAGE;
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
type GetArtworkImageParams = {
|
|
99
|
-
key: string;
|
|
100
|
-
entry: ZappEntry;
|
|
101
|
-
plugin_configuration: Record<string, any>;
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
export const getArtworkImage = ({
|
|
105
|
-
key,
|
|
106
|
-
entry,
|
|
107
|
-
plugin_configuration,
|
|
108
|
-
}: GetArtworkImageParams): string => {
|
|
109
|
-
// 1) image_key from extensions
|
|
110
|
-
const imageKeyFromExtensions = getPropertyFromExtensions(key, entry);
|
|
111
|
-
|
|
112
|
-
const imageFromExtensions = getImageFromEntry({
|
|
113
|
-
entry,
|
|
114
|
-
imageKey: imageKeyFromExtensions,
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
if (imageFromExtensions) {
|
|
118
|
-
return imageFromExtensions;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
// 2) image_key from configuration
|
|
122
|
-
const imageKeyFromConfiguration = getPropertyFromConfiguration(
|
|
123
|
-
key,
|
|
124
|
-
plugin_configuration
|
|
125
|
-
);
|
|
126
|
-
|
|
127
|
-
const imageFromConfiguration = getImageFromEntry({
|
|
128
|
-
entry,
|
|
129
|
-
imageKey: imageKeyFromConfiguration,
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
if (imageFromConfiguration) {
|
|
133
|
-
return imageFromConfiguration;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
// default image
|
|
137
|
-
return DEFAULT_IMAGE;
|
|
138
|
-
};
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { selectActionButtons } from "@applicaster/zapp-react-native-utils/conf/player/selectors";
|
|
2
|
-
|
|
3
|
-
describe("selectActionButtons", () => {
|
|
4
|
-
it("returns the player_action_buttons array if present", () => {
|
|
5
|
-
const pluginConf = {
|
|
6
|
-
player_action_buttons: [
|
|
7
|
-
{ id: "like", label: "Like" },
|
|
8
|
-
{ id: "share", label: "Share" },
|
|
9
|
-
],
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
expect(selectActionButtons(pluginConf)).toEqual(
|
|
13
|
-
pluginConf.player_action_buttons
|
|
14
|
-
);
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
it("returns null if player_action_buttons is not present", () => {
|
|
18
|
-
const pluginConf = { some_other_key: [] };
|
|
19
|
-
expect(selectActionButtons(pluginConf)).toBeNull();
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
it("returns null if pluginConf is undefined", () => {
|
|
23
|
-
expect(selectActionButtons(undefined)).toBeNull();
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
it("returns null if pluginConf is null", () => {
|
|
27
|
-
expect(selectActionButtons(null)).toBeNull();
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
it("returns null if player_action_buttons is explicitly set to null", () => {
|
|
31
|
-
const pluginConf = { player_action_buttons: null };
|
|
32
|
-
expect(selectActionButtons(pluginConf)).toBeNull();
|
|
33
|
-
});
|
|
34
|
-
});
|
package/conf/player/selectors.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { get } from "@applicaster/zapp-react-native-utils/utils";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Selects the action buttons from the player configuration.
|
|
5
|
-
* @param {Object} pluginConf - player plugin config
|
|
6
|
-
* @returns {Array|null} An array of action buttons or null if not found.
|
|
7
|
-
*/
|
|
8
|
-
export const selectActionButtons = (pluginConf: any) => {
|
|
9
|
-
return get(pluginConf, "player_action_buttons", null);
|
|
10
|
-
};
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { getMediaItems } from "..";
|
|
2
|
-
import { entry as baseEntry } from "./testEntry";
|
|
3
|
-
|
|
4
|
-
describe("getMediaItems", () => {
|
|
5
|
-
it("returns both image and thumbnail media items", () => {
|
|
6
|
-
const items = getMediaItems(baseEntry);
|
|
7
|
-
expect(items).toHaveLength(2);
|
|
8
|
-
expect(items[0].key).toBe("image_base");
|
|
9
|
-
expect(items[1].key).toBe("logo_thumbnail");
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
it("returns only image media items if no thumbnail present", () => {
|
|
13
|
-
const entry = {
|
|
14
|
-
...baseEntry,
|
|
15
|
-
media_group: [
|
|
16
|
-
{
|
|
17
|
-
type: "image",
|
|
18
|
-
media_item: [
|
|
19
|
-
{ key: "image_base", src: "img.png" },
|
|
20
|
-
{ key: "other", src: "other.png" },
|
|
21
|
-
],
|
|
22
|
-
},
|
|
23
|
-
],
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
const items = getMediaItems(entry);
|
|
27
|
-
expect(items).toHaveLength(2);
|
|
28
|
-
expect(items[0].key).toBe("image_base");
|
|
29
|
-
expect(items[1].key).toBe("other");
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
it("returns only thumbnail media items if no image present", () => {
|
|
33
|
-
const entry = {
|
|
34
|
-
...baseEntry,
|
|
35
|
-
media_group: [
|
|
36
|
-
{
|
|
37
|
-
type: "thumbnail",
|
|
38
|
-
media_item: [{ key: "thumb1", src: "thumb1.png" }],
|
|
39
|
-
},
|
|
40
|
-
],
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
const items = getMediaItems(entry);
|
|
44
|
-
expect(items).toHaveLength(1);
|
|
45
|
-
expect(items[0].key).toBe("thumb1");
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
it("returns undefined if no media_group present", () => {
|
|
49
|
-
const entry = { ...baseEntry };
|
|
50
|
-
delete entry.media_group;
|
|
51
|
-
expect(getMediaItems(entry)).toBeUndefined();
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
it("returns undefined if media_group is present but has no image or thumbnail", () => {
|
|
55
|
-
const entry = {
|
|
56
|
-
...baseEntry,
|
|
57
|
-
media_group: [
|
|
58
|
-
{ type: "audio", media_item: [{ key: "audio1", src: "audio1.mp3" }] },
|
|
59
|
-
],
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
const items = getMediaItems(entry);
|
|
63
|
-
expect(items).toBeUndefined();
|
|
64
|
-
});
|
|
65
|
-
});
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import * as R from "ramda";
|
|
2
|
-
import { imageSrcFromMediaItem } from "../";
|
|
3
|
-
import { entry } from "./testEntry";
|
|
4
|
-
|
|
5
|
-
describe("imageSrcFromMediaItem", () => {
|
|
6
|
-
it("when the matching key is found and the src is not empty", () => {
|
|
7
|
-
const result = imageSrcFromMediaItem(entry as ZappEntry, [
|
|
8
|
-
"logo_thumbnail",
|
|
9
|
-
]);
|
|
10
|
-
|
|
11
|
-
expect(result).toEqual(entry.media_group[1].media_item[0].src);
|
|
12
|
-
expect(result).not.toEqual("");
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
it("returns a media item with the 'image_base' key as a fallback", () => {
|
|
16
|
-
const result = imageSrcFromMediaItem(entry as ZappEntry, [
|
|
17
|
-
"does_not_exist",
|
|
18
|
-
]);
|
|
19
|
-
|
|
20
|
-
const fallback = entry.media_group[0].media_item[0];
|
|
21
|
-
expect(result).toEqual(fallback.src);
|
|
22
|
-
expect(fallback.key).toBe("image_base");
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
it("returns undefined if the key was found but the source was empty", () => {
|
|
26
|
-
const badEntry: ZappEntry = R.set(
|
|
27
|
-
R.lensPath(["media_group", 0, "media_item", 0, "src"]),
|
|
28
|
-
"",
|
|
29
|
-
entry
|
|
30
|
-
);
|
|
31
|
-
|
|
32
|
-
expect(imageSrcFromMediaItem(badEntry, ["image_base"])).toBeUndefined();
|
|
33
|
-
});
|
|
34
|
-
});
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { getPlayerActionButtons } from "../getPlayerActionButtons";
|
|
2
|
-
import { selectActionButtons } from "../../conf/player/selectors";
|
|
3
|
-
|
|
4
|
-
jest.mock("../../conf/player/selectors", () => ({
|
|
5
|
-
selectActionButtons: jest.fn(),
|
|
6
|
-
}));
|
|
7
|
-
|
|
8
|
-
describe("getPlayerActionButtons", () => {
|
|
9
|
-
afterEach(() => {
|
|
10
|
-
jest.clearAllMocks();
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
it("returns an empty array if selectActionButtons returns undefined", () => {
|
|
14
|
-
(selectActionButtons as jest.Mock).mockReturnValue(undefined);
|
|
15
|
-
const result = getPlayerActionButtons({});
|
|
16
|
-
expect(result).toEqual([]);
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
it("returns an empty array if selectActionButtons returns null", () => {
|
|
20
|
-
(selectActionButtons as jest.Mock).mockReturnValue(null);
|
|
21
|
-
const result = getPlayerActionButtons({});
|
|
22
|
-
expect(result).toEqual([]);
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
it("returns an empty array if selectActionButtons returns empty string", () => {
|
|
26
|
-
(selectActionButtons as jest.Mock).mockReturnValue("");
|
|
27
|
-
const result = getPlayerActionButtons({});
|
|
28
|
-
expect(result).toEqual([]);
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
it("returns the first two trimmed action buttons", () => {
|
|
32
|
-
(selectActionButtons as jest.Mock).mockReturnValue(" play , pause , stop ");
|
|
33
|
-
const result = getPlayerActionButtons({});
|
|
34
|
-
expect(result).toEqual(["play", "pause"]);
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
it("returns only one button if only one is present", () => {
|
|
38
|
-
(selectActionButtons as jest.Mock).mockReturnValue(" play ");
|
|
39
|
-
const result = getPlayerActionButtons({});
|
|
40
|
-
expect(result).toEqual(["play"]);
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
it("trims whitespace from button names", () => {
|
|
44
|
-
(selectActionButtons as jest.Mock).mockReturnValue(" play , pause ");
|
|
45
|
-
const result = getPlayerActionButtons({});
|
|
46
|
-
expect(result).toEqual(["play", "pause"]);
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
it("returns an empty array if selectActionButtons returns only commas", () => {
|
|
50
|
-
(selectActionButtons as jest.Mock).mockReturnValue(" , , ");
|
|
51
|
-
const result = getPlayerActionButtons({});
|
|
52
|
-
expect(result).toEqual(["", ""]);
|
|
53
|
-
});
|
|
54
|
-
});
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { take, map, trim } from "lodash";
|
|
2
|
-
import { selectActionButtons } from "../conf/player/selectors";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Returns the first two action buttons from the configuration.
|
|
6
|
-
* @param {Object} configuration - The player configuration object.
|
|
7
|
-
* @returns {Array} An array containing the first two action buttons.
|
|
8
|
-
*/
|
|
9
|
-
export const getPlayerActionButtons = (configuration: any) => {
|
|
10
|
-
const buttonsString = selectActionButtons(configuration);
|
|
11
|
-
|
|
12
|
-
if (!buttonsString) {
|
|
13
|
-
return [];
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
return take(map(buttonsString.split(","), trim), 2);
|
|
17
|
-
};
|