@24i/bigscreen-sdk 0.9.9-alpha.2149 → 0.9.9-alpha.2151

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.
Files changed (24) hide show
  1. package/__mocks__/@24i/bigscreen-sdk/animations.ts +2 -0
  2. package/package.json +2 -1
  3. package/packages/animations/src/__mocks__/JSAnimations.ts +30 -0
  4. package/packages/conviva/src/__mocks__/ConvivaMock.ts +36 -0
  5. package/packages/developer-tools/src/TechnicalInfo/__mocks__/Device.ts +51 -0
  6. package/packages/developer-tools/src/TechnicalInfo/__mocks__/Player.ts +7 -0
  7. package/packages/developer-tools/src/TechnicalInfo/__mocks__/Storage.ts +9 -0
  8. package/packages/driver-base/src/__mocks__/DeviceBase.ts +100 -0
  9. package/packages/driver-base/src/__mocks__/keyMap.ts +41 -0
  10. package/packages/driver-entone/src/__mocks__/entone.ts +177 -0
  11. package/packages/driver-hbbtv/src/__mocks__/hbbtv.ts +17 -0
  12. package/packages/driver-kreatv/src/__mocks__/toi2.ts +76 -0
  13. package/packages/driver-kreatv/src/__mocks__/toi3.ts +43 -0
  14. package/packages/driver-saphi/src/__mocks__/SmartTvA_API.ts +11 -0
  15. package/packages/driver-saphi/src/__mocks__/userAgent.ts +4 -0
  16. package/packages/driver-tizen/src/__mocks__/tizen.ts +35 -0
  17. package/packages/driver-webos/src/__mocks__/webos.ts +172 -0
  18. package/packages/driver-xbox/src/__mocks__/Windows.ts +94 -0
  19. package/packages/gallup/src/__mocks__/SpringStreams.js +18 -0
  20. package/packages/input/__mocks__/MockKeyboard.ts +40 -0
  21. package/packages/logger/src/__mocks__/LoggerBase.ts +13 -0
  22. package/packages/logger/src/loggers/SentryLogger/mock.ts +6 -0
  23. package/packages/utils/src/xhr/__mocks__/xhr.ts +29 -0
  24. package/packages/volume-control/src/__mocks__/VolumeControlUIMock.tsx +18 -0
@@ -0,0 +1,2 @@
1
+ export { AnimationUtils } from '@24i/bigscreen-sdk/animations';
2
+ export { JSAnimations } from '@24i/bigscreen-sdk/animations/mock';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@24i/bigscreen-sdk",
3
- "version": "0.9.9-alpha.2149",
3
+ "version": "0.9.9-alpha.2151",
4
4
  "description": "SmartApps BIGscreen SDK monorepo",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -188,6 +188,7 @@
188
188
  "./list/interface": "./packages/list/src/interface.ts",
189
189
  "./list/utils": "./packages/list/utils/index.ts",
190
190
  "./logger/ConsoleLogger": "./packages/logger/src/loggers/ConsoleLogger/index.ts",
191
+ "./logger/SentryLogger/mock": "./packages/logger/src/loggers/SentryLogger/mock.ts",
191
192
  "./logger/SentryLogger": "./packages/logger/src/loggers/SentryLogger/index.ts",
192
193
  "./logger": "./packages/logger/src/index.ts",
193
194
  "./lottie-animations": "./packages/lottie-animations/src/index.ts",
@@ -0,0 +1,30 @@
1
+ export class JSAnimations {
2
+ animationRunning = false;
3
+
4
+ from = 0;
5
+
6
+ to = 0;
7
+
8
+ frameCallback?: (value: number) => void;
9
+
10
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
11
+ start(from: number, to: number, time: number, easingFunction: any): JSAnimations {
12
+ this.to = to;
13
+ this.animationRunning = true;
14
+ this.frameCallback = undefined;
15
+ setTimeout(this.frame, 0);
16
+ return this;
17
+ }
18
+
19
+ frame = (): void => {
20
+ if (this.frameCallback) {
21
+ this.frameCallback(this.to);
22
+ }
23
+ };
24
+
25
+ onFrame(callback: (value: number) => void) {
26
+ if (typeof callback === 'function') {
27
+ this.frameCallback = callback;
28
+ }
29
+ }
30
+ }
@@ -0,0 +1,36 @@
1
+ import type { ConvivaSDK } from '../ConvivaSDK';
2
+
3
+ export const ConvivaMock: ConvivaSDK = {
4
+ Constants: {
5
+ StreamType: {
6
+ LIVE: 'LIVE',
7
+ VOD: 'VOD',
8
+ },
9
+ LogLevel: {
10
+ DEBUG: 0,
11
+ INFO: 1,
12
+ WARNING: 2,
13
+ ERROR: 3,
14
+ NONE: 4,
15
+ },
16
+ DeviceMetadata: {
17
+ MANUFACTURER: 'MANUFACTURER',
18
+ MODEL: 'MODEL',
19
+ TYPE: 'TYPE',
20
+ },
21
+ DeviceType: {
22
+ SMARTTV: 'SMARTTV',
23
+ },
24
+ ASSET_NAME: 'ASSET_NAME',
25
+ CUSTOMER_KEY: 'CUSTOMER_KEY',
26
+ DEFAULT_RESOURCE: 'DEFAULT_RESOURCE',
27
+ DURATION: 'DURATION',
28
+ ENCODED_FRAMERATE: 'ENCODED_FRAMERATE',
29
+ GATEWAY_URL: 'GATEWAY_URL',
30
+ IS_LIVE: 'IS_LIVE',
31
+ LOG_LEVEL: 'LOG_LEVEL',
32
+ PLAYER_NAME: 'PLAYER_NAME',
33
+ STREAM_URL: 'STREAM_URL',
34
+ VIEWER_ID: 'VIEWER_ID',
35
+ },
36
+ };
@@ -0,0 +1,51 @@
1
+ class Device {
2
+ async getUuid() {
3
+ return 'uuidXYZ';
4
+ }
5
+
6
+ async getManufacturerName() {
7
+ return 'manufacturer name';
8
+ }
9
+
10
+ async getPlatformName() {
11
+ return 'platform name';
12
+ }
13
+
14
+ async getPlatformVersion() {
15
+ return 'platform version';
16
+ }
17
+
18
+ async getDeviceName() {
19
+ return 'device name';
20
+ }
21
+
22
+ async getModelName() {
23
+ return 'model name';
24
+ }
25
+
26
+ async getFirmware() {
27
+ return 'device firmware';
28
+ }
29
+
30
+ async is4KSupported() {
31
+ return true;
32
+ }
33
+
34
+ async is8KSupported() {
35
+ return false;
36
+ }
37
+
38
+ async getLocalIP() {
39
+ return 'local ip';
40
+ }
41
+
42
+ async getConnectionType() {
43
+ return 'connection type';
44
+ }
45
+
46
+ async getMacAddress() {
47
+ return 'mac address';
48
+ }
49
+ }
50
+
51
+ export { Device };
@@ -0,0 +1,7 @@
1
+ class Player {
2
+ static playerName = 'PlayerEngine';
3
+
4
+ static version = 'v1.0.0';
5
+ }
6
+
7
+ export { Player };
@@ -0,0 +1,9 @@
1
+ /* eslint-disable no-magic-numbers */
2
+
3
+ class Storage {
4
+ async getUsedSize() {
5
+ return 2048; // 2 kB
6
+ }
7
+ }
8
+
9
+ export { Storage };
@@ -0,0 +1,100 @@
1
+ import { DeviceBase as AbstractDeviceBase } from '../DeviceBase';
2
+ import { ScreenSaverStatus } from '../types/ScreenSaverStatus';
3
+ import { ConnectionType } from '../ConnectionType';
4
+
5
+ export class DeviceBase extends AbstractDeviceBase {
6
+ volume = 0;
7
+
8
+ isMuted = false;
9
+
10
+ screenSaverStatus = { enabled: false };
11
+
12
+ async initDevice() {
13
+ return undefined;
14
+ }
15
+
16
+ exit() {}
17
+
18
+ reboot() {}
19
+
20
+ async getManufacturerName() {
21
+ return 'manufacturer name';
22
+ }
23
+
24
+ async getPlatformName() {
25
+ return 'platform name';
26
+ }
27
+
28
+ async getPlatformVersion() {
29
+ return 'platform version';
30
+ }
31
+
32
+ async getDeviceName() {
33
+ return 'device name';
34
+ }
35
+
36
+ async getModelName() {
37
+ return 'model name';
38
+ }
39
+
40
+ async getFirmware() {
41
+ return 'device firmware';
42
+ }
43
+
44
+ async is4KSupported() {
45
+ return true;
46
+ }
47
+
48
+ async is8KSupported() {
49
+ return false;
50
+ }
51
+
52
+ async getUuid() {
53
+ return this.getBaseUuid();
54
+ }
55
+
56
+ async getVolume() {
57
+ return this.volume;
58
+ }
59
+
60
+ async setVolume(volumePercentage: number) {
61
+ this.volume = volumePercentage;
62
+ }
63
+
64
+ async mute(mute: boolean) {
65
+ this.isMuted = mute;
66
+ }
67
+
68
+ async isMute() {
69
+ return this.isMuted;
70
+ }
71
+
72
+ async getScreenSaver() {
73
+ return this.screenSaverStatus;
74
+ }
75
+
76
+ async setScreenSaver(status: ScreenSaverStatus) {
77
+ this.screenSaverStatus.enabled = status.enabled;
78
+ }
79
+
80
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
81
+ async setUserAgent(userAgent: string) {
82
+ return false;
83
+ }
84
+
85
+ async isNetworkConnected() {
86
+ return true;
87
+ }
88
+
89
+ async getConnectionType() {
90
+ return 'unknown' as ConnectionType;
91
+ }
92
+
93
+ async getLocalIP() {
94
+ return '1.2.3.4';
95
+ }
96
+
97
+ async getMacAddress() {
98
+ return '00:11:22:33:44:55';
99
+ }
100
+ }
@@ -0,0 +1,41 @@
1
+ export const KEYMAP = {
2
+ LEFT: 37,
3
+ RIGHT: 39,
4
+ UP: 38,
5
+ DOWN: 40,
6
+ BACK: 8,
7
+ ENTER: 13,
8
+ ESC: 27,
9
+ PLAY: 415,
10
+ PAUSE: 19,
11
+ PLAYPAUSE: 1000,
12
+ STOP: 413,
13
+ FF: 417,
14
+ REW: 412,
15
+ RED: 82,
16
+ GREEN: 71,
17
+ YELLOW: 89,
18
+ BLUE: 66,
19
+ NUM_0: 48,
20
+ NUM_1: 49,
21
+ NUM_2: 50,
22
+ NUM_3: 51,
23
+ NUM_4: 52,
24
+ NUM_5: 53,
25
+ NUM_6: 54,
26
+ NUM_7: 55,
27
+ NUM_8: 56,
28
+ NUM_9: 57,
29
+ KP_0: 96,
30
+ KP_1: 97,
31
+ KP_2: 98,
32
+ KP_3: 99,
33
+ KP_4: 100,
34
+ KP_5: 101,
35
+ KP_6: 102,
36
+ KP_7: 103,
37
+ KP_8: 104,
38
+ KP_9: 105,
39
+ CHANNEL_UP: 33,
40
+ CHANNEL_DOWN: 34,
41
+ };
@@ -0,0 +1,177 @@
1
+ /* eslint-disable no-magic-numbers */
2
+ import { INetworkCallback, NetworkEvent, UserAgentMode } from '../IEntone';
3
+
4
+ /**
5
+ * Internal mock state
6
+ */
7
+ export const entoneState = {
8
+ volumePercentage: 100,
9
+ isMuted: false,
10
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
11
+ networkEventCallback: (event: NetworkEvent, param?: any) => {},
12
+ dispatchEventNetworkLinkDown: () => {
13
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define
14
+ const { NETWORK_LINK_STATUS_DOWN } = ENTONE.network;
15
+ entoneState.networkEventCallback({ status: NETWORK_LINK_STATUS_DOWN });
16
+ },
17
+ dispatchEventNetworkLinkUp: () => {
18
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define
19
+ const { NETWORK_LINK_STATUS_UP } = ENTONE.network;
20
+ entoneState.networkEventCallback({ status: NETWORK_LINK_STATUS_UP });
21
+ },
22
+ };
23
+
24
+ /**
25
+ * Mocking Entone API module.
26
+ * Note: Constant values were grabbed from Kamai 500
27
+ */
28
+ export const ENTONE = {
29
+ status: {
30
+ ACCESS_DENIED: 'ENTONE.status.ACCESS_DENIED',
31
+ ALREADY_EXIST: 'ENTONE.status.ALREADY_EXIST',
32
+ DIR_NOT_EMPTY: 'ENTONE.status.DIR_NOT_EMPTY',
33
+ ERROR: 'ENTONE.status.ERROR',
34
+ INVALID_ARGUMENT: 'ENTONE.status.INVALID_ARGUMENT',
35
+ NOT_EXIST: 'ENTONE.status.NOT_EXIST',
36
+ NOT_IMPLEMENTED: 'ENTONE.status.NOT_IMPLEMENTED',
37
+ NOT_PERMITTED: 'ENTONE.status.NOT_PERMITTED',
38
+ NOT_READY: 'ENTONE.status.NOT_READY',
39
+ RESOURCE_BUSY: 'ENTONE.status.RESOURCE_BUSY',
40
+ SUCCESS: 'ENTONE.status.SUCCESS',
41
+ TIMED_OUT: 'ENTONE.status.TIMED_OUT',
42
+ },
43
+ input: {
44
+ KEY_0: 48,
45
+ KEY_1: 49,
46
+ KEY_2: 50,
47
+ KEY_3: 51,
48
+ KEY_4: 52,
49
+ KEY_5: 53,
50
+ KEY_6: 54,
51
+ KEY_7: 55,
52
+ KEY_8: 56,
53
+ KEY_9: 57,
54
+ KEY_AUDIO: 57469,
55
+ KEY_BACK: 8,
56
+ KEY_BLUE: 57508,
57
+ KEY_CHANNELDOWN: 57510,
58
+ KEY_CHANNELUP: 57509,
59
+ KEY_CLOSED_CAPTION: 57545,
60
+ KEY_DISPLAY: 57459,
61
+ KEY_DOWN: 40,
62
+ KEY_ENTER: 13,
63
+ KEY_EXIT: 27,
64
+ KEY_FASTFORWARD: 57529,
65
+ KEY_FAVORITES: 57465,
66
+ KEY_GREEN: 57506,
67
+ KEY_GUIDE: 58744,
68
+ KEY_INFO: 57459,
69
+ KEY_INPUT: 58745,
70
+ KEY_LANG: 57469,
71
+ KEY_LAST: 57514,
72
+ KEY_LEFT: 37,
73
+ KEY_LIST: 57500,
74
+ KEY_MENU: 57457,
75
+ KEY_MUSIC: 57398,
76
+ KEY_MUTE: 57517,
77
+ KEY_NEXTCHAPTER: 57531,
78
+ KEY_OPTIONS: 57456,
79
+ KEY_PAUSE: 57519,
80
+ KEY_PLAY: 57520,
81
+ KEY_PLAYPAUSE: 57519,
82
+ KEY_POWER: 57454,
83
+ KEY_PREVIOUSCHAPTER: 57530,
84
+ KEY_PVR: 57400,
85
+ KEY_RECORD: 57525,
86
+ KEY_RED: 57505,
87
+ KEY_REWIND: 57528,
88
+ KEY_RIGHT: 39,
89
+ KEY_STOP: 57521,
90
+ KEY_TELETEXT: 57544,
91
+ KEY_TV: 57478,
92
+ KEY_UP: 38,
93
+ KEY_VOD: 57397,
94
+ KEY_VOLUMEDOWN: 57516,
95
+ KEY_VOLUMEUP: 57515,
96
+ KEY_YELLOW: 57507,
97
+ },
98
+ network: {
99
+ EVENT_WIFI_LIST_UPDATED: 'wifi_list_updated',
100
+ NETWORK_LINK_STATUS_DOWN: 28676,
101
+ NETWORK_LINK_STATUS_ETH_DOWN: 28678,
102
+ NETWORK_LINK_STATUS_ETH_UP: 28677,
103
+ NETWORK_LINK_STATUS_UP: 28675,
104
+ NETWORK_READY: 28674,
105
+ nic_type: {
106
+ CAT5: 1,
107
+ HPNA: 2,
108
+ WIFI: 4,
109
+ MOCA: 8,
110
+ VIF: 16,
111
+ },
112
+ getConfig: () => ({
113
+ status: ENTONE.status.SUCCESS,
114
+ result: {
115
+ acs_last_contacted: 1618358446,
116
+ auto_cfg_flags: 1,
117
+ current_active_wan: 'eth0',
118
+ dhcp_last_contacted: 1618309092,
119
+ dns_1st: '8.8.8.8',
120
+ dns_2nd: '8.8.4.4',
121
+ gateway: '172.16.15.254',
122
+ hostname: '26-38746151',
123
+ network: [{
124
+ ip_address: '172.16.12.148',
125
+ mac_address: '00:03:e6:76:3e:6e',
126
+ netmask: '255.255.252.0',
127
+ nic_name: 'eth0',
128
+ nic_type: 1,
129
+ }],
130
+ ntp_last_contacted: 1617704286,
131
+ ntp_server: '255.255.255.255',
132
+ num_of_nic: 1,
133
+ },
134
+ }),
135
+ setNetworkEvtCallback: (callback: INetworkCallback) => {
136
+ entoneState.networkEventCallback = callback;
137
+ },
138
+ },
139
+ stb: {
140
+ reboot: () => {},
141
+ getHardwareModel: () => 26, // 26 for Kamai 500
142
+ getSoftwareVersion: () => '2.9.32_build10-etv-vmx--as3',
143
+ getSerialNumber: () => '38746151',
144
+ getAudioVolume: () => ({
145
+ status_code: ENTONE.status.SUCCESS,
146
+ leftVolPercentage: entoneState.volumePercentage,
147
+ rightVolPercentage: entoneState.volumePercentage,
148
+ }),
149
+ setAudioVolume: (
150
+ leftVolPercentage: number,
151
+ rightVolPercentage: number,
152
+ callback?: (status: string) => void,
153
+ ) => {
154
+ const input = { leftVolPercentage, rightVolPercentage, callback };
155
+ entoneState.volumePercentage = input.leftVolPercentage;
156
+ },
157
+ mute: (isMuted: boolean) => {
158
+ entoneState.isMuted = isMuted;
159
+ },
160
+ getMute: () => entoneState.isMuted,
161
+ },
162
+ browser: {
163
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
164
+ configUserAgent: (options: {
165
+ id: number,
166
+ user_agent_mode: UserAgentMode,
167
+ user_agent: string,
168
+ }) => ENTONE.status.SUCCESS,
169
+ },
170
+ };
171
+
172
+ declare global {
173
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
174
+ interface Window {
175
+ ENTONE: typeof ENTONE,
176
+ }
177
+ }
@@ -0,0 +1,17 @@
1
+ const objectOIPF = document.createElement('object');
2
+
3
+ export const mockApplication = {
4
+ show: () => ({}),
5
+ activate: () => ({}),
6
+ destroyApplication: () => ({}),
7
+ privateData: {
8
+ keyset: {
9
+ setValue: () => ({}),
10
+ },
11
+ },
12
+ };
13
+
14
+ export const mockApplicationManager = {
15
+ ...objectOIPF,
16
+ getOwnerApplication: () => (mockApplication),
17
+ };
@@ -0,0 +1,76 @@
1
+ import { ToiHTMLEmbedElement } from '../types';
2
+
3
+ export const toi = {
4
+ consts: {
5
+ ToiAudioOutputService: {
6
+ AUDIO_CONNECTION_TYPE_ANALOG: 0,
7
+ AUDIO_CONNECTION_TYPE_SPDIF: 1,
8
+ AUDIO_CONNECTION_TYPE_HDMI: 2,
9
+ },
10
+ ToiPowerControl: {
11
+ ACCESS_REPORT_ONLY: 0,
12
+ ON_POWER_PROFILE_REQUESTED: 4400,
13
+ ON_POWER_PROFILE_SELECTED: 4401,
14
+ PROFILE_ACTIVE: 0,
15
+ },
16
+ ToiPlatformService: {
17
+ REBOOT_TYPE_NOW: 0,
18
+ },
19
+ ToiNetService: {
20
+ ON_DEVICE_INTERFACE_READINESS_CHANGED: 4406,
21
+ },
22
+ ToiNetConfiguration: {
23
+ NET_DEVICE_TYPE_ALL: 255,
24
+ NET_DEVICE_TYPE_ETHERNET: 1,
25
+ NET_DEVICE_TYPE_WIFI: 16,
26
+ },
27
+ ToiInformationService: {
28
+ CONST_IP_ETH0_MAC: 'const.ip.eth0.mac',
29
+ VAR_IP_ETH0_ADDR: 'var.ip.eth0.addr',
30
+ CONST_FW_VERSION: 'const._fw.version',
31
+ CONST_HW_PRODUCTNAME: 'const.hw.productname',
32
+ CONST_HW_SERIALNUMBER: 'const.hw.serialnumber',
33
+ },
34
+ },
35
+ audioOutputService: {
36
+ getConnections: jest.fn().mockReturnValue([
37
+ { id: 1, type: 1 },
38
+ { id: 2, type: 2 },
39
+ { id: 4, type: 4 },
40
+ ]),
41
+ getVolume: jest.fn(),
42
+ setVolume: jest.fn(),
43
+ setMuteState: jest.fn(),
44
+ getMuteState: jest.fn(),
45
+ },
46
+ netService: {
47
+ addEventListener: jest.fn(),
48
+ getConfiguration: jest.fn().mockReturnValue({
49
+ getNetworkDevices: jest.fn().mockReturnValue([]),
50
+ getGenericDeviceInfo: jest.fn(),
51
+ }),
52
+ },
53
+ informationService: {
54
+ getObject: jest.fn(),
55
+ },
56
+ platformService: {
57
+ reboot: jest.fn(),
58
+ createPowerControlInstance: jest.fn().mockReturnValue({
59
+ addEventListener: jest.fn(),
60
+ reportPowerProfile: jest.fn(),
61
+ reportPowerProfileActionsComplete: jest.fn(),
62
+ }),
63
+ },
64
+ };
65
+
66
+ export const mockToiHtmlEmbedElement = document.createElement('embed') as ToiHTMLEmbedElement;
67
+ mockToiHtmlEmbedElement.id = 'toiplugin';
68
+
69
+ export const mockConnectionType = (connectionType?: number) => {
70
+ toi.netService.getConfiguration.mockReturnValueOnce({
71
+ getNetworkDevices: jest.fn().mockReturnValueOnce([]),
72
+ getGenericDeviceInfo: jest.fn().mockReturnValueOnce(
73
+ { type: connectionType },
74
+ ),
75
+ });
76
+ };
@@ -0,0 +1,43 @@
1
+ /* eslint-disable no-magic-numbers */
2
+
3
+ export const toi = {
4
+ version: '',
5
+ consts: {
6
+ ToiNetService: {
7
+ BOOT_NETWORK: '_boot_network_',
8
+ },
9
+ ToiNetwork: {
10
+ ON_NETWORK_INFO_CHANGED: 4500,
11
+ STATE_READY: 3,
12
+ INTERFACE_TYPE_ETHERNET: 0,
13
+ INTERFACE_TYPE_WIFI: 1,
14
+ },
15
+ },
16
+ netService: {
17
+ getNetwork: jest.fn().mockReturnValue({
18
+ addEventListener: jest.fn(),
19
+ getNetworkInfo: jest.fn(),
20
+ }),
21
+ getNetworkInterfaces: jest.fn(),
22
+ },
23
+ };
24
+
25
+ export const mockConnectionType = (connectionType?: number) => {
26
+ toi.netService.getNetwork.mockReturnValueOnce({
27
+ getNetworkInfo: jest.fn().mockReturnValueOnce({
28
+ interfaceInfo: { type: connectionType },
29
+ }),
30
+ });
31
+ };
32
+
33
+ export const mockXMLHttpRequest = (
34
+ readyState = 4, status = 200, send: Function = jest.fn(),
35
+ ) => {
36
+ // @ts-ignore - mocking purpose
37
+ window.XMLHttpRequest = jest.fn().mockImplementation(() => ({
38
+ open: jest.fn(),
39
+ send,
40
+ readyState,
41
+ status,
42
+ }));
43
+ };
@@ -0,0 +1,11 @@
1
+ // eslint-disable-next-line @typescript-eslint/naming-convention
2
+ export const SmartTvA_API = {
3
+ hasCapability: jest.fn(),
4
+ exit: jest.fn(),
5
+ };
6
+
7
+ declare global {
8
+ interface Window {
9
+ SmartTvA_API: typeof SmartTvA_API,
10
+ }
11
+ }
@@ -0,0 +1,4 @@
1
+ export const mockUserAgent = 'Mozilla/5.0 (Linux armv7l) AppleWebKit/537.36 (KHTML, like Gecko) '
2
+ + 'Chrome/49.0.2623.112 Safari/537.36 OPR/36.0.2128.0 OMI/4.8.0.129.Driver3.56 , '
3
+ + '_TV_MT5802/012.004.070.051 (Philips, PUS6162, wireless) CE-HTML/1.0 NETTV/4.6.0 '
4
+ + 'SignOn/2.0 SmartTvA/5.0.0 en Opera/68.0.3618.31';
@@ -0,0 +1,35 @@
1
+ export const webapis = {
2
+ network: {
3
+ addNetworkStateChangeListener: () => {},
4
+ },
5
+ productinfo: {
6
+ getDuid: () => 'guid',
7
+ getRealModel: () => 'real model',
8
+ getModelCode: () => 'model code',
9
+ getFirmware: () => 'firmware',
10
+ },
11
+ };
12
+
13
+ export const application = {
14
+ hide: jest.fn(),
15
+ exit: jest.fn(),
16
+ };
17
+
18
+ export const tizen = {
19
+ application: {
20
+ getCurrentApplication: () => application,
21
+ },
22
+ tvinputdevice: {
23
+ getSupportedKeys: (): any[] => [],
24
+ unregisterKey: () => {},
25
+ registerKey: () => {},
26
+ },
27
+ };
28
+
29
+ declare global {
30
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
31
+ interface Window {
32
+ webapis: typeof webapis,
33
+ tizen: typeof tizen,
34
+ }
35
+ }
@@ -0,0 +1,172 @@
1
+ /**
2
+ * Mocking services response module
3
+ */
4
+ const mockServices = {
5
+ timeoutMs: 1,
6
+ setServiceResponse(serviceId: string, responseId: string, callbackName: string) {
7
+ const service = this.getService(serviceId);
8
+ service.selected.responseId = responseId;
9
+ service.selected.callbackName = callbackName;
10
+ },
11
+ getServiceResponse(serviceId: string, responseId: string) {
12
+ const service = this.getService(serviceId);
13
+ return service.responses[responseId];
14
+ },
15
+ getService(serviceId: string) {
16
+ return (this.services as any)[serviceId];
17
+ },
18
+ services: {
19
+ 'luna://com.webos.service.tv.systemproperty#getSystemInfo': {
20
+ responses: {
21
+ success: {
22
+ returnValue: true,
23
+ modelName: 'LB6700AKR',
24
+ firmwareVersion: '3.00.00',
25
+ UHD: 'true',
26
+ sdkVersion: '1.05.00',
27
+ },
28
+ successHD: {
29
+ returnValue: true,
30
+ modelName: 'LB6700AKR',
31
+ firmwareVersion: '3.00.00',
32
+ UHD: 'false',
33
+ sdkVersion: '1.05.00',
34
+ },
35
+ error: {
36
+ returnValue: false,
37
+ errorCode: 'ERROR_10',
38
+ errorText: 'Resource temporarily unavailable',
39
+ },
40
+ },
41
+ selected: {
42
+ responseId: 'success',
43
+ callbackName: 'onSuccess',
44
+ },
45
+ },
46
+ 'luna://com.webos.service.sm#deviceid/getIDs': {
47
+ responses: {
48
+ success: {
49
+ returnValue: true,
50
+ idList: [{
51
+ idType: 'LGUDID',
52
+ idValue: '095f142a-xxxx-yyyy',
53
+ }],
54
+ },
55
+ error: {
56
+ returnValue: false,
57
+ errorCode: 'ERR.002',
58
+ errorText: 'Security Manager Internal Error',
59
+ },
60
+ },
61
+ selected: {
62
+ responseId: 'success',
63
+ callbackName: 'onSuccess',
64
+ },
65
+ },
66
+ 'luna://com.webos.service.connectionmanager#getStatus': {
67
+ responses: {
68
+ successWired: {
69
+ returnValue: true,
70
+ subscribed: true,
71
+ isInternetConnectionAvailable: true,
72
+ wired: {
73
+ state: 'connected',
74
+ netmask: '255.255.254.0',
75
+ dns1: '123.456.789.180',
76
+ ipAddress: '123.456.789.12',
77
+ onInternet: 'yes',
78
+ method: 'manual',
79
+ gateway: '123.456.789.1',
80
+ interfaceName: 'eth0',
81
+ },
82
+ wifi: {
83
+ state: 'disconnected',
84
+ },
85
+ wifiDirect: {
86
+ state: 'disconnected',
87
+ },
88
+ },
89
+ successWiFi: {
90
+ returnValue: true,
91
+ subscribed: true,
92
+ isInternetConnectionAvailable: true,
93
+ wired: {
94
+ state: 'disconnected',
95
+ },
96
+ wifi: {
97
+ state: 'connected',
98
+ netmask: '255.255.254.0',
99
+ ipAddress: '172.0.0.0',
100
+ onInternet: 'yes',
101
+ },
102
+ wifiDirect: {
103
+ state: 'disconnected',
104
+ },
105
+ },
106
+ error: {
107
+ returnValue: false,
108
+ errorCode: 'ERROR CODE',
109
+ errorText: 'Error text',
110
+ },
111
+ },
112
+ selected: {
113
+ responseId: 'successWired',
114
+ callbackName: 'onSuccess',
115
+ },
116
+ },
117
+ },
118
+ };
119
+
120
+ /**
121
+ * Mocking webOS module
122
+ */
123
+ export const webOS = {
124
+ libVersion: '1.2.3',
125
+ platform: {
126
+ tv: true,
127
+ },
128
+ keyboard: {
129
+ isShowing: () => false,
130
+ },
131
+ service: {
132
+ request(uri: string, params?: any) {
133
+ const serviceId = `${uri}#${params.method}`;
134
+ const mockService = mockServices.getService(serviceId);
135
+
136
+ if (mockService) {
137
+ const { responseId, callbackName } = mockService.selected;
138
+ const mockResponse = mockService.responses[responseId];
139
+
140
+ setTimeout(() => {
141
+ params[callbackName].call(this, mockResponse);
142
+ }, mockService.timeoutMs);
143
+ }
144
+ },
145
+ },
146
+ mockServices,
147
+ deviceInfo: (callback: (deviceInfo: Object) => void) => {
148
+ callback({
149
+ modelName: 'webos model name',
150
+ modelNameAscii: 'webos name ascii',
151
+ version: 'webos version 3.4.5',
152
+ sdkVersion: 'webos sdkversion 3.3.0',
153
+ screenWidth: 1920,
154
+ screenHeight: 1080,
155
+ uhd: false,
156
+ uhd8K: false,
157
+ });
158
+ },
159
+ fetchAppId: () => 'com.24i.mock',
160
+ };
161
+
162
+ export const PalmSystem = {
163
+ deactivate: jest.fn(),
164
+ };
165
+
166
+ declare global {
167
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
168
+ interface Window {
169
+ webOS: typeof webOS,
170
+ PalmSystem: typeof PalmSystem,
171
+ }
172
+ }
@@ -0,0 +1,94 @@
1
+ import {
2
+ DeviceInformation,
3
+ HostName,
4
+ InternetConnectionProfile,
5
+ IVirtualKey,
6
+ NetworkConnectivityLevel,
7
+ Windows as IWindows,
8
+ } from '../interfaces';
9
+
10
+ const networkAdapter = {
11
+ networkAdapterId: 'networkAdapterId',
12
+ };
13
+
14
+ export const getNetworkConnectivityLevel = jest.fn(() => NetworkConnectivityLevel.internetAccess);
15
+
16
+ class EasClientDeviceInformation implements DeviceInformation {
17
+ friendlyName = 'friendlyName';
18
+
19
+ id = 'id';
20
+
21
+ operatingSystem = 'operatingSystem';
22
+
23
+ systemFirmwareVersion = 'systemFirmwareVersion';
24
+
25
+ systemHardwareVersion = 'systemHardwareVersion';
26
+
27
+ systemManufacturer = 'systemManufacturer';
28
+
29
+ systemProductName = 'systemProductName';
30
+
31
+ systemSku = 'systemSku';
32
+ }
33
+
34
+ export const Windows: IWindows = {
35
+ Networking: {
36
+ Connectivity: {
37
+ NetworkConnectivityLevel,
38
+ NetworkInformation: {
39
+ getHostNames: jest.fn((): HostName[] => ([{
40
+ ipInformation: {
41
+ networkAdapter,
42
+ },
43
+ }])),
44
+ getInternetConnectionProfile: jest.fn((): InternetConnectionProfile => ({
45
+ networkAdapter,
46
+ getNetworkConnectivityLevel,
47
+ isWlanConnectionProfile: true,
48
+ })),
49
+ onnetworkstatuschanged: () => {},
50
+ },
51
+ },
52
+ },
53
+ Security: {
54
+ ExchangeActiveSyncProvisioning: {
55
+ EasClientDeviceInformation,
56
+ },
57
+ },
58
+ Storage: {
59
+ ApplicationData: {
60
+ current: {
61
+ localSettings: {
62
+ values: {
63
+ storedUuid: '11b4a2a3-cd33-46e6-b43f-a0c2a42427e6',
64
+ },
65
+ },
66
+ },
67
+ },
68
+ },
69
+ System: {
70
+ VirtualKey: {
71
+ left: 37,
72
+ up: 38,
73
+ right: 39,
74
+ down: 40,
75
+ enter: 13,
76
+ back: 8,
77
+ } as IVirtualKey,
78
+ Profile: {
79
+ AnalyticsInfo: {
80
+ versionInfo: {
81
+ deviceFamilyVersion: '2814750438211613',
82
+ },
83
+ },
84
+ },
85
+ },
86
+ };
87
+
88
+ window.Windows = Windows;
89
+
90
+ declare global {
91
+ interface Window {
92
+ Windows: IWindows,
93
+ }
94
+ }
@@ -0,0 +1,18 @@
1
+ const streamSpy = {
2
+ stop: jest.fn(),
3
+ };
4
+
5
+ const sensorsSpy = {
6
+ track: jest.fn(() => streamSpy),
7
+ unload: jest.fn(),
8
+ debug: undefined,
9
+ };
10
+
11
+ const SpringStreams = jest.fn(() => sensorsSpy);
12
+
13
+ window.SpringStreams = SpringStreams;
14
+
15
+ module.exports = {
16
+ streamSpy,
17
+ sensorsSpy,
18
+ };
@@ -0,0 +1,40 @@
1
+ export class MockKeyboard {
2
+ listener: Function | null = null;
3
+
4
+ resolver: Function | null = null;
5
+
6
+ inputElement: HTMLInputElement | null = null;
7
+
8
+ promise: Promise<void> | null = null;
9
+
10
+ input: (input: HTMLInputElement) => Promise<void> = jest.fn(
11
+ (inputElement: HTMLInputElement) => {
12
+ this.promise = new Promise((resolve) => {
13
+ this.inputElement = inputElement;
14
+ this.resolver = resolve;
15
+ });
16
+ return this.promise;
17
+ },
18
+ );
19
+
20
+ done = () => {
21
+ if (this.resolver) {
22
+ this.inputElement = null;
23
+ this.resolver();
24
+ this.resolver = null;
25
+ }
26
+ };
27
+
28
+ addEventListener = (_: any, listener: Function) => {
29
+ this.listener = listener;
30
+ };
31
+
32
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
33
+ removeEventListener = (_: any, listener: any) => {
34
+ this.listener = null;
35
+ };
36
+
37
+ triggerEvent = (payload: any) => {
38
+ if (this.listener) this.listener(payload);
39
+ };
40
+ }
@@ -0,0 +1,13 @@
1
+ /* eslint-disable @typescript-eslint/no-unused-vars */
2
+ import { LoggerBase as AbstractLoggerBase } from '../loggers/LoggerBase';
3
+ import { LogOptions } from '../types';
4
+
5
+ export class LoggerBase extends AbstractLoggerBase {
6
+ debug(message: string, options?: LogOptions) {}
7
+
8
+ info(message: string, options?: LogOptions) {}
9
+
10
+ warn(message: string, options?: LogOptions) {}
11
+
12
+ error(message: string, options?: LogOptions) {}
13
+ }
@@ -0,0 +1,6 @@
1
+ import { Sentry } from './Sentry';
2
+
3
+ jest.mock('./Sentry');
4
+
5
+ export { SentryLogger } from './SentryLogger';
6
+ export { Sentry };
@@ -0,0 +1,29 @@
1
+ function mockXhr(status?: number, responseData?: string) {
2
+ const mockXhrObj = {
3
+ open: jest.fn(),
4
+ send: jest.fn(),
5
+ ontimeout: jest.fn(),
6
+ onerror: jest.fn(),
7
+ onabort: jest.fn(),
8
+ onload: jest.fn(),
9
+ setRequestHeader: jest.fn(),
10
+ readyState: 4,
11
+ status,
12
+ response: responseData,
13
+ timeout: undefined as undefined | number,
14
+ };
15
+
16
+ const mockXhrClass = () => mockXhrObj;
17
+
18
+ // @ts-ignore - Needed for mocking purposes
19
+ window.XMLHttpRequest = jest.fn().mockImplementation(mockXhrClass);
20
+
21
+ setTimeout(() => {
22
+ // @ts-ignore - Needed for mocking purposes
23
+ mockXhrObj.onload();
24
+ }, 0);
25
+
26
+ return mockXhrObj;
27
+ }
28
+
29
+ export { mockXhr };
@@ -0,0 +1,18 @@
1
+ import { Component } from '@24i/bigscreen-sdk/jsx';
2
+ import { IVolumeControlUI } from '../IVolumeControlUI';
3
+
4
+ export class VolumeControlUIMock extends Component<{}> implements IVolumeControlUI {
5
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
6
+ onUpdateVolume(volumeLevel: number) {}
7
+
8
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
9
+ onUpdateMute(isMuted: boolean) {}
10
+
11
+ show = () => {};
12
+
13
+ hide = () => {};
14
+
15
+ isVisible() { return true; }
16
+
17
+ render() { return <div className="volume-control-ui" />; }
18
+ }