@applicaster/zapp-react-native-utils 14.0.0-alpha.6335583720 → 14.0.0-alpha.7140739134

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.
@@ -0,0 +1,34 @@
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
+ });
@@ -0,0 +1,10 @@
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
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applicaster/zapp-react-native-utils",
3
- "version": "14.0.0-alpha.6335583720",
3
+ "version": "14.0.0-alpha.7140739134",
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.6335583720",
30
+ "@applicaster/applicaster-types": "14.0.0-alpha.7140739134",
31
31
  "buffer": "^5.2.1",
32
32
  "camelize": "^1.0.0",
33
33
  "dayjs": "^1.11.10",
@@ -0,0 +1,54 @@
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
+ });
@@ -0,0 +1,17 @@
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
+ };
@@ -6,6 +6,8 @@ import { isTV } from "@applicaster/zapp-react-native-utils/reactUtils";
6
6
 
7
7
  import { getBoolFromConfigValue } from "../configurationUtils";
8
8
 
9
+ export { getPlayerActionButtons } from "./getPlayerActionButtons";
10
+
9
11
  /**
10
12
  * Gets duration value from player manager, and from extensions
11
13
  * then checks whether the value from either is a not a valid number
@@ -144,11 +144,11 @@ export const useBatchLoading = (
144
144
  }
145
145
  }
146
146
  });
147
- }, [feedUrls]);
147
+ }, [feedUrls, feeds]);
148
148
 
149
149
  React.useEffect(() => {
150
150
  runBatchLoading();
151
- }, []);
151
+ }, [runBatchLoading]); // Adding runBatchLoading as a dependency to ensure that it reloads feeds when clearPipesData is called
152
152
 
153
153
  React.useEffect(() => {
154
154
  // check if all feeds are ready and set hasEverBeenReady to true
package/utils/index.ts CHANGED
@@ -9,4 +9,5 @@ export {
9
9
  size,
10
10
  isNil,
11
11
  isEmpty,
12
+ get,
12
13
  } from "lodash";