@24i/bigscreen-sdk 1.0.4 → 1.0.5-4.alpha-2832
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/README.md +2 -3
- package/ci/is_ci_job_skippable.sh +153 -0
- package/package.json +55 -34
- package/packages/adobe-heartbeat/src/AdobeHeartbeat.ts +9 -9
- package/packages/analytics/README.md +8 -0
- package/packages/analytics/src/A.ts +1 -0
- package/packages/analytics/src/Analytics.ts +1 -0
- package/packages/analytics/src/analyticsOnScroll.ts +1 -0
- package/packages/analytics/src/clients/ConsoleAnalytics/ConsoleAnalytics.ts +1 -0
- package/packages/analytics/src/clients/ConsoleAnalytics/index.ts +1 -0
- package/packages/analytics/src/clients/GoogleAnalytics/GoogleAnalytics.ts +196 -0
- package/packages/analytics/src/clients/GoogleAnalytics/constants.ts +126 -0
- package/packages/analytics/src/clients/GoogleAnalytics/getUrl.ts +17 -0
- package/packages/analytics/src/clients/GoogleAnalytics/index.ts +2 -0
- package/packages/analytics/src/clients/GoogleAnalytics/interface.ts +82 -0
- package/packages/analytics/src/clients/GoogleAnalytics/mapPayload.ts +51 -0
- package/packages/analytics/src/clients/GoogleAnalytics/prepareBody.ts +14 -0
- package/packages/analytics/src/clients/TealiumAnalytics/TealiumAnalytics.ts +181 -0
- package/packages/analytics/src/clients/TealiumAnalytics/constants.ts +106 -0
- package/packages/analytics/src/clients/TealiumAnalytics/findForLanguage.ts +9 -0
- package/packages/analytics/src/clients/TealiumAnalytics/index.ts +4 -0
- package/packages/analytics/src/clients/TealiumAnalytics/interface.ts +35 -0
- package/packages/analytics/src/clients/TealiumAnalytics/mappers/__mocks__/mediaPayload.ts +72 -0
- package/packages/analytics/src/clients/TealiumAnalytics/mappers/helper.ts +36 -0
- package/packages/analytics/src/clients/TealiumAnalytics/mappers/mapAppError.ts +13 -0
- package/packages/analytics/src/clients/TealiumAnalytics/mappers/mapAppOpen.ts +13 -0
- package/packages/analytics/src/clients/TealiumAnalytics/mappers/mapFavoriteAdd.ts +11 -0
- package/packages/analytics/src/clients/TealiumAnalytics/mappers/mapFavoriteRemove.ts +11 -0
- package/packages/analytics/src/clients/TealiumAnalytics/mappers/mapPlayerClose.ts +15 -0
- package/packages/analytics/src/clients/TealiumAnalytics/mappers/mapPlayerOpen.ts +15 -0
- package/packages/analytics/src/clients/TealiumAnalytics/mappers/mapSceneView.ts +18 -0
- package/packages/analytics/src/clients/TealiumAnalytics/mappers/mapSearch.ts +18 -0
- package/packages/analytics/src/clients/TealiumAnalytics/mappers/mapSearchFailed.ts +8 -0
- package/packages/analytics/src/clients/TealiumAnalytics/mappers/mapSearchSuccess.ts +8 -0
- package/packages/analytics/src/clients/TealiumAnalytics/mappers/mapVideoPause.ts +15 -0
- package/packages/analytics/src/clients/TealiumAnalytics/mappers/mapVideoProgress.ts +18 -0
- package/packages/analytics/src/clients/TealiumAnalytics/mappers/mapVideoResume.ts +15 -0
- package/packages/analytics/src/clients/TealiumAnalytics/mappers/mapVideoStart.ts +15 -0
- package/packages/analytics/src/clients/TealiumAnalytics/mappers/mapVideoStop.ts +15 -0
- package/packages/analytics/src/clients/TealiumAnalytics/types.ts +161 -0
- package/packages/analytics/src/clients/TwentyFourIQ/TwentyFourIQClient.ts +107 -0
- package/packages/analytics/src/clients/TwentyFourIQ/constants.ts +111 -0
- package/packages/analytics/src/clients/TwentyFourIQ/helper.ts +34 -0
- package/packages/analytics/src/clients/TwentyFourIQ/index.ts +2 -0
- package/packages/analytics/src/clients/TwentyFourIQ/interface.ts +34 -0
- package/packages/analytics/src/clients/TwentyFourIQ/mappers/mapAdEvent.ts +20 -0
- package/packages/analytics/src/clients/TwentyFourIQ/mappers/mapBase.ts +24 -0
- package/packages/analytics/src/clients/TwentyFourIQ/mappers/mapBuffering.ts +15 -0
- package/packages/analytics/src/clients/TwentyFourIQ/mappers/mapPlayerClose.ts +25 -0
- package/packages/analytics/src/clients/TwentyFourIQ/mappers/mapPlayerOpen.ts +17 -0
- package/packages/analytics/src/clients/TwentyFourIQ/mappers/mapSceneView.ts +15 -0
- package/packages/analytics/src/clients/TwentyFourIQ/mappers/mapScroll.ts +17 -0
- package/packages/analytics/src/clients/TwentyFourIQ/mappers/mapVideoComplete.ts +22 -0
- package/packages/analytics/src/clients/TwentyFourIQ/mappers/mapVideoPause.ts +25 -0
- package/packages/analytics/src/clients/TwentyFourIQ/mappers/mapVideoProgress.ts +25 -0
- package/packages/analytics/src/clients/TwentyFourIQ/mappers/mapVideoStart.ts +34 -0
- package/packages/analytics/src/clients/TwentyFourIQ/mappers/mapVideoStop.ts +32 -0
- package/packages/analytics/src/clients/TwentyFourIQ/types.ts +132 -0
- package/packages/analytics/src/constants.ts +1 -0
- package/packages/analytics/src/index.ts +3 -0
- package/packages/analytics/src/interface.ts +1 -0
- package/packages/analytics/src/utils/generateSessionId.ts +8 -0
- package/packages/async-image/src/AsyncImage.tsx +15 -10
- package/packages/developer-tools/PlayerDebugWindow/README.md +1 -1
- package/packages/developer-tools/src/DeveloperConsole/DeveloperConsole.tsx +1 -0
- package/packages/developer-tools/src/DeveloperToolsService/DeveloperToolsList.tsx +11 -0
- package/packages/developer-tools/src/PlayerDebugWindow/PlayerDebugWindow.tsx +5 -5
- package/packages/developer-tools/src/PlayerDebugWindow/constants.ts +15 -0
- package/packages/developer-tools/src/TechnicalInfo/TechnicalInfo.tsx +2 -0
- package/packages/developer-tools/src/TechnicalInfo/TechnicalInfoDetail.tsx +2 -1
- package/packages/developer-tools/src/TechnicalInfo/TechnicalInfoProvider.ts +57 -5
- package/packages/developer-tools/src/TechnicalInfo/__mocks__/Device.ts +12 -0
- package/packages/developer-tools/src/TechnicalInfo/translations.ts +8 -0
- package/packages/device/src/driver/index.android.tv.ts +1 -0
- package/packages/device/src/driver/index.firetv.ts +1 -0
- package/packages/device/src/driver/index.smartcast.tv.ts +1 -0
- package/packages/device/src/getKeyDigit.ts +2 -2
- package/packages/device/src/resolver/resolver.ts +19 -0
- package/packages/digital-clock/src/DigitalClock.tsx +15 -4
- package/packages/driver-androidtv/src/DeviceAndroidTV.ts +262 -0
- package/packages/driver-androidtv/src/__mocks__/javaScriptBridge.ts +45 -0
- package/packages/driver-androidtv/src/formatUserAgent.ts +11 -0
- package/packages/driver-androidtv/src/index.ts +2 -0
- package/packages/driver-androidtv/src/keymap.ts +27 -0
- package/packages/driver-androidtv/src/types.ts +155 -0
- package/packages/driver-base/src/DeviceBase.ts +73 -2
- package/packages/driver-base/src/KeyMap/Key.ts +8 -1
- package/packages/driver-base/src/KeyMap/KeyMap.ts +4 -0
- package/packages/driver-base/src/KeyMap/interface.ts +1 -0
- package/packages/driver-base/src/KeyMap/overrideValues.ts +2 -1
- package/packages/driver-base/src/__mocks__/DeviceBase.ts +24 -0
- package/packages/driver-base/src/__mocks__/keyMap.ts +1 -0
- package/packages/driver-base/src/index.ts +3 -0
- package/packages/driver-base/src/types/AdInfo.ts +5 -0
- package/packages/driver-base/src/types/DeviceEvent.ts +2 -0
- package/packages/driver-base/src/types/InAppPurchase.ts +20 -0
- package/packages/driver-base/src/types/KeycodeKeyMap.ts +1 -0
- package/packages/driver-browser/src/DeviceBrowser.ts +26 -0
- package/packages/driver-browser/src/keymap.ts +8 -0
- package/packages/driver-entone/src/DeviceEntone.ts +31 -1
- package/packages/driver-entone/src/keymap.ts +1 -0
- package/packages/driver-firetv/src/DeviceFireTV.ts +86 -0
- package/packages/driver-firetv/src/__mocks__/javaScriptBridge.ts +45 -0
- package/packages/driver-firetv/src/index.ts +1 -0
- package/packages/driver-firetv/src/types.ts +1 -0
- package/packages/driver-hbbtv/src/DeviceHbbTV.ts +26 -0
- package/packages/driver-kreatv/src/DeviceKreaTV.ts +26 -0
- package/packages/driver-saphi/src/DeviceSaphi.ts +26 -0
- package/packages/driver-smartcast/src/DeviceSmartCast.ts +380 -0
- package/packages/driver-smartcast/src/__mocks__/api.ts +69 -0
- package/packages/driver-smartcast/src/index.ts +1 -0
- package/packages/driver-smartcast/src/keymap.ts +9 -0
- package/packages/driver-smartcast/src/types.ts +102 -0
- package/packages/driver-tizen/src/DeviceTizen.ts +121 -7
- package/packages/driver-tizen/src/ITizen.ts +15116 -202
- package/packages/driver-tizen/src/IWebapis.ts +8643 -87
- package/packages/driver-tizen/src/TizenKeys.ts +4 -2
- package/packages/driver-tizen/src/__mocks__/tizen.ts +7 -8
- package/packages/driver-tizen/src/constants.ts +1 -195
- package/packages/driver-vidaa/src/DeviceVidaa.ts +29 -2
- package/packages/driver-vidaa/src/__mocks__/vidaa.ts +1 -1
- package/packages/driver-vidaa/src/keymap.ts +2 -0
- package/packages/driver-webos/src/DeviceWebos.ts +55 -0
- package/packages/driver-webos/src/__mocks__/webos.ts +33 -0
- package/packages/driver-webos/src/constants.ts +1 -0
- package/packages/driver-webos/src/keymap.ts +2 -1
- package/packages/driver-webos/src/types.ts +30 -0
- package/packages/driver-xbox/src/DeviceXbox.ts +30 -1
- package/packages/driver-xbox/src/keymap.ts +1 -1
- package/packages/epg/README.md +3 -1
- package/packages/epg/src/v2/Cell.tsx +16 -2
- package/packages/epg/src/v2/DataManager.ts +112 -41
- package/packages/epg/src/v2/DatePicker.tsx +9 -3
- package/packages/epg/src/v2/DateToast/DateToast.tsx +12 -9
- package/packages/epg/src/v2/Day.tsx +6 -3
- package/packages/epg/src/v2/Epg.tsx +5 -5
- package/packages/epg/src/v2/MockGenerator/generator.ts +3 -2
- package/packages/epg/src/v2/ProgramInfo/utils.ts +4 -3
- package/packages/epg/src/v2/Row.tsx +3 -1
- package/packages/epg/src/v2/TimelineSection.tsx +4 -1
- package/packages/epg/src/v2/basic/CellsManager.tsx +7 -2
- package/packages/epg/src/v2/basic/RowsManager.tsx +3 -1
- package/packages/epg/src/v2/interface.ts +13 -0
- package/packages/events-manager/src/EventsManager.ts +1 -56
- package/packages/focus/README.md +33 -0
- package/packages/focus/src/IFocusable.ts +1 -0
- package/packages/focus/src/Layout/Base.tsx +41 -6
- package/packages/focus/src/Layout/Matrix.tsx +51 -19
- package/packages/focus/src/focusFirstExisting.ts +7 -1
- package/packages/focus/src/hasFocus.ts +36 -0
- package/packages/focus/src/index.ts +2 -1
- package/packages/gallup/src/Gallup.ts +3 -3
- package/packages/grid/src/Base/Base.tsx +15 -10
- package/packages/grid/src/FirstOnlyGrid/FirstOnlyGrid.tsx +4 -2
- package/packages/grid/src/UnifiedGridController/UnifiedGridController.ts +6 -6
- package/packages/icon/src/Icon.tsx +27 -5
- package/packages/input/README.md +1 -1
- package/packages/input/src/Input.tsx +10 -10
- package/packages/interactable/README.md +2 -1
- package/packages/interactable/src/Interactable.tsx +9 -3
- package/packages/interactable/src/interface.ts +1 -0
- package/packages/jsx/src/index.ts +1 -1
- package/packages/jsx/src/test-utils/index.ts +1 -0
- package/packages/jsx/src/test-utils/keyup.ts +27 -0
- package/packages/keyboard/README.md +2 -0
- package/packages/keyboard/src/Backdrop/Backdrop.scss +2 -0
- package/packages/keyboard/src/KeyboardBase.tsx +16 -4
- package/packages/keyboard/src/WhitelabelKeyboard/Keyboard.scss +10 -0
- package/packages/keyboard/src/WhitelabelKeyboard/Keyboard.tsx +128 -142
- package/packages/keyboard/src/WhitelabelKeyboard/WhitelabelStyles/whitelabel.scss +4 -0
- package/packages/keyboard/src/WhitelabelKeyboard/_sizes.1080.scss +1 -0
- package/packages/keyboard/src/WhitelabelKeyboard/_sizes.scss +1 -0
- package/packages/keyboard/src/WhitelabelKeyboard/icons/key_language.svg +20 -0
- package/packages/keyboard/src/WhitelabelKeyboard/index.ts +1 -1
- package/packages/keyboard/src/WhitelabelKeyboard/layouts/arabic.ts +27 -0
- package/packages/keyboard/src/WhitelabelKeyboard/layouts/burmese.ts +27 -0
- package/packages/keyboard/src/WhitelabelKeyboard/layouts/dari.ts +28 -0
- package/packages/keyboard/src/WhitelabelKeyboard/layouts/hebrew.ts +28 -0
- package/packages/keyboard/src/WhitelabelKeyboard/layouts/index.ts +15 -0
- package/packages/keyboard/src/WhitelabelKeyboard/layouts/korean.ts +26 -0
- package/packages/keyboard/src/WhitelabelKeyboard/layouts/latin.ts +26 -0
- package/packages/keyboard/src/WhitelabelKeyboard/layouts/pashto.ts +27 -0
- package/packages/keyboard/src/WhitelabelKeyboard/layouts/persian.ts +27 -0
- package/packages/keyboard/src/WhitelabelKeyboard/layouts/russian.ts +27 -0
- package/packages/keyboard/src/WhitelabelKeyboard/layouts/spanish.ts +26 -0
- package/packages/keyboard/src/WhitelabelKeyboard/layouts/special.ts +28 -0
- package/packages/keyboard/src/WhitelabelKeyboard/layouts/tibetan.ts +26 -0
- package/packages/keyboard/src/WhitelabelKeyboard/layouts/turkish.ts +26 -0
- package/packages/keyboard/src/WhitelabelKeyboard/layouts/ukrainian.ts +27 -0
- package/packages/keyboard/src/WhitelabelKeyboard/layouts/urdu.ts +26 -0
- package/packages/keyboard/src/WhitelabelKeyboard/types.ts +22 -2
- package/packages/keyboard/src/types/index.ts +1 -1
- package/packages/keyboard/src/utils/caret.ts +5 -8
- package/packages/keyboard/src/utils/input.ts +5 -6
- package/packages/keyboard/src/utils/setInputSelectionRange.ts +10 -0
- package/packages/l10n/README.md +18 -0
- package/packages/l10n/src/date/common.ts +18 -6
- package/packages/l10n/src/date/cs.ts +2 -8
- package/packages/l10n/src/date/de.ts +97 -0
- package/packages/l10n/src/date/en-001.ts +3 -3
- package/packages/l10n/src/date/en-common.ts +5 -4
- package/packages/l10n/src/date/en-us.ts +3 -3
- package/packages/l10n/src/date/es.ts +71 -0
- package/packages/l10n/src/date/fr.ts +94 -0
- package/packages/l10n/src/date/he.ts +101 -0
- package/packages/l10n/src/date/iso.ts +12 -13
- package/packages/l10n/src/date/types.ts +9 -0
- package/packages/l10n/src/l10n.ts +61 -3
- package/packages/list/src/Base/Base.tsx +19 -9
- package/packages/list/src/Base/interface.ts +2 -2
- package/packages/list/src/BasicList/BasicList.tsx +7 -7
- package/packages/list/src/CenteredList/CenteredList.tsx +2 -2
- package/packages/list/src/CenteredList/controller.ts +0 -1
- package/packages/list/src/EdgeOffsetList/EdgeOffsetList.tsx +10 -10
- package/packages/list/src/FirstOnlyList/FirstOnlyList.tsx +2 -2
- package/packages/list/src/FirstOnlyVariedList/FirstOnlyVariedList.tsx +2 -2
- package/packages/list/src/FixedToEndList/FixedToEndList.tsx +2 -2
- package/packages/list/src/UnifiedListController/UnifiedListController.ts +6 -2
- package/packages/list/src/interface.ts +2 -2
- package/packages/logger/src/loggers/ConsoleLogger/ConsoleLogger.ts +7 -1
- package/packages/logger/src/loggers/SentryLogger/Sentry.ts +1 -0
- package/packages/logger/src/loggers/SentryLogger/SentryLogger.ts +5 -3
- package/packages/menu/src/MenuAndContentContainer/MenuAndContentContainer.tsx +31 -3
- package/packages/menu/src/MenuAndContentContainer/interface.ts +8 -0
- package/packages/modal-service/README.md +4 -1
- package/packages/modal-service/src/ModalService.tsx +29 -5
- package/packages/perf-utils/README.md +1 -120
- package/packages/perf-utils/src/array/filter.ts +1 -54
- package/packages/perf-utils/src/array/find.ts +1 -43
- package/packages/perf-utils/src/array/findIndex.ts +1 -43
- package/packages/perf-utils/src/array/forEach.ts +1 -48
- package/packages/perf-utils/src/array/includes.ts +1 -41
- package/packages/perf-utils/src/array/includesNaN.ts +1 -32
- package/packages/perf-utils/src/array/index.ts +1 -7
- package/packages/perf-utils/src/array/map.ts +1 -52
- package/packages/player-ui/README.md +1 -1
- package/packages/player-ui/src/CurrentTime.tsx +2 -2
- package/packages/player-ui/src/Duration.tsx +2 -2
- package/packages/player-ui/src/PauseButton.tsx +8 -0
- package/packages/player-ui/src/PlayerInteractable.tsx +1 -0
- package/packages/player-ui/src/PlayerTime.tsx +3 -1
- package/packages/player-ui/src/PlayerUI.tsx +68 -35
- package/packages/player-ui/src/RemainingTime.tsx +2 -2
- package/packages/player-ui/src/Seekbar.tsx +110 -18
- package/packages/player-ui/src/Seeking.ts +57 -16
- package/packages/player-ui/src/Subtitles.tsx +2 -2
- package/packages/player-ui/src/index.ts +1 -0
- package/packages/player-ui/src/mocks.ts +32 -8
- package/packages/player-ui/src/timeUtils.ts +3 -3
- package/packages/player-ui/src/types.ts +9 -3
- package/packages/router/README.md +1 -0
- package/packages/router/src/Route.tsx +61 -27
- package/packages/router/src/Router.tsx +63 -14
- package/packages/router/src/history.ts +8 -1
- package/packages/router/src/index.ts +1 -1
- package/packages/router/src/utils.ts +9 -4
- package/packages/sass-utils/src/linear-gradient.scss +9 -4
- package/packages/sass-utils/src/scale.1080.scss +3 -1
- package/packages/sass-utils/src/scale.720.scss +1 -1
- package/packages/time/README.md +4 -1
- package/packages/time/src/Time.ts +35 -13
- package/packages/time/src/adapters/24iMediaTimeApi.ts +47 -0
- package/packages/time/src/constants.ts +1 -0
- package/packages/time/src/services/24iMediaTimeApi/24iMediaTimeApi.ts +43 -0
- package/packages/time/src/services/24iMediaTimeApi/index.ts +6 -0
- package/packages/toast/src/ToastService.scss +1 -0
- package/packages/toast/src/ToastService.tsx +16 -5
- package/packages/types-bigscreen-jsx/README.md +5 -4
- package/packages/types-bigscreen-jsx/index.d.ts +72 -67
- package/packages/utils/README.md +27 -0
- package/packages/utils/src/elementUtils.ts +25 -0
- package/packages/utils/src/forceReflow.ts +14 -0
- package/packages/utils/src/index.ts +8 -0
- package/packages/utils/src/keyPress/index.ts +6 -0
- package/packages/utils/src/keyPress/keyPressSimulator.ts +74 -0
- package/packages/utils/src/keyPress/simulateKeyPress.ts +25 -0
- package/packages/utils/src/scaledImage.ts +6 -3
- package/packages/utils/src/textUtils.ts +46 -14
- package/packages/utils/src/wait.ts +3 -1
- package/packages/utils/src/xhr/xhrSend.ts +3 -1
- package/packages/utils/src/xhr/xhrSendRetry.ts +3 -1
- package/packages/zapping/src/ChannelZapping.ts +9 -0
- package/packages/zapping/src/Zapping.tsx +10 -0
- package/utils/release/release.ts +156 -0
- package/packages/driver-tizen/src/types.ts +0 -14
- package/packages/focus/src/Layout/__test__/Base.spec.ts +0 -180
- package/packages/focus/src/Layout/__test__/Horizontal.spec.ts +0 -94
- package/packages/focus/src/Layout/__test__/Matrix.spec.ts +0 -261
- package/packages/focus/src/Layout/__test__/Vertical.spec.ts +0 -46
- package/packages/focus/src/Layout/__test__/isRtl.spec.ts +0 -23
- package/packages/focus/src/Layout/__test__/shared.ts +0 -19
- package/packages/keyboard/src/WhitelabelKeyboard/focusMatrix.ts +0 -19
|
@@ -1,180 +0,0 @@
|
|
|
1
|
-
import { IFocusable } from '../../IFocusable';
|
|
2
|
-
import { getLayoutBase } from '../Base';
|
|
3
|
-
import { rootRef, refChildA, refChildB, refChildC, refChildD } from './shared';
|
|
4
|
-
|
|
5
|
-
const mockKeydown = jest.fn();
|
|
6
|
-
const mockEvent: any = {
|
|
7
|
-
target: null,
|
|
8
|
-
preventDefault: jest.fn(),
|
|
9
|
-
stopPropagation: jest.fn(),
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
const Base = getLayoutBase(mockKeydown);
|
|
13
|
-
|
|
14
|
-
describe('Focus Layout Base', () => {
|
|
15
|
-
let base: any;
|
|
16
|
-
beforeEach(() => {
|
|
17
|
-
base = new Base({
|
|
18
|
-
domRef: rootRef,
|
|
19
|
-
children: 'children',
|
|
20
|
-
focusableChildren: [refChildA, refChildB, refChildC],
|
|
21
|
-
onFocusChanged: jest.fn(),
|
|
22
|
-
onBeforeFocusChange: jest.fn(),
|
|
23
|
-
});
|
|
24
|
-
mockKeydown.mockClear();
|
|
25
|
-
refChildA.current!.focus.mockClear();
|
|
26
|
-
refChildB.current!.focus.mockClear();
|
|
27
|
-
refChildC.current!.focus.mockClear();
|
|
28
|
-
mockEvent.preventDefault.mockClear();
|
|
29
|
-
mockEvent.stopPropagation.mockClear();
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
it('should throw without domRef on componentDidMount', () => {
|
|
33
|
-
// @ts-ignore - the point of the test is to test possible runtime problem
|
|
34
|
-
const invalidBase = new Base({ domRef: null, children: [], focusableChildren: [] });
|
|
35
|
-
expect(() => invalidBase.componentDidMount()).toThrow();
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
it('should throw without domRef on componentWillUnmount', () => {
|
|
39
|
-
// @ts-ignore - the point of the test is to test possible runtime problem
|
|
40
|
-
const invalidBase = new Base({ domRef: null, children: [], focusableChildren: [] });
|
|
41
|
-
expect(() => invalidBase.componentWillUnmount()).toThrow();
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
it('should not throw with valid domRef on componentDidMount', () => {
|
|
45
|
-
expect(() => base.componentDidMount()).not.toThrow();
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
it('should not throw with valid domRef on componentWillUnmount', () => {
|
|
49
|
-
expect(() => base.componentWillUnmount()).not.toThrow();
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
it('should render children', () => {
|
|
53
|
-
expect(base.render()).toBe('children');
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
it('should return false when setting index out of range', () => {
|
|
57
|
-
expect(base.setIndex(4)).toBe(false);
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
it('should return true when setting index out of range', () => {
|
|
61
|
-
expect(base.setIndex(1)).toBe(true);
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
it('should increase index by one on forward', () => {
|
|
65
|
-
const oldIndex = base.index;
|
|
66
|
-
base.forward(mockEvent);
|
|
67
|
-
expect(base.index).toBe(oldIndex + 1);
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
it('should deecrease index by one on backward', () => {
|
|
71
|
-
base.index = 2;
|
|
72
|
-
const oldIndex = base.index;
|
|
73
|
-
base.backward(mockEvent);
|
|
74
|
-
expect(base.index).toBe(oldIndex - 1);
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
it('should not increase index above focusableChildren.length - 1', () => {
|
|
78
|
-
base.index = base.props.focusableChildren.length - 1;
|
|
79
|
-
base.forward(mockEvent);
|
|
80
|
-
expect(base.index).toBe(base.props.focusableChildren.length - 1);
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
it('should not decrease index below 0', () => {
|
|
84
|
-
base.index = 0;
|
|
85
|
-
base.backward(mockEvent);
|
|
86
|
-
expect(base.index).toBe(0);
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
it('should call focus on new element when going forward', () => {
|
|
90
|
-
base.forward(mockEvent);
|
|
91
|
-
expect(refChildB.current!.focus).toHaveBeenCalled();
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
it('should call focus on new element when going backward', () => {
|
|
95
|
-
base.index = 1;
|
|
96
|
-
base.backward(mockEvent);
|
|
97
|
-
expect(refChildA.current!.focus).toHaveBeenCalled();
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
it('should not call focus when can\'t go forward', () => {
|
|
101
|
-
base.index = 2;
|
|
102
|
-
base.forward(mockEvent);
|
|
103
|
-
expect(refChildC.current!.focus).not.toHaveBeenCalled();
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
it('should not call focus when can\'t go backward', () => {
|
|
107
|
-
base.backward(mockEvent);
|
|
108
|
-
expect(refChildA.current!.focus).not.toHaveBeenCalled();
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
it('should call preventDefault and stopPropagation when going forward', () => {
|
|
112
|
-
base.forward(mockEvent);
|
|
113
|
-
expect(mockEvent.preventDefault).toHaveBeenCalled();
|
|
114
|
-
expect(mockEvent.stopPropagation).toHaveBeenCalled();
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
it('should call preventDefault and stopPropagation when going backward', () => {
|
|
118
|
-
base.index = 1;
|
|
119
|
-
base.backward(mockEvent);
|
|
120
|
-
expect(mockEvent.preventDefault).toHaveBeenCalled();
|
|
121
|
-
expect(mockEvent.stopPropagation).toHaveBeenCalled();
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
it('should not call preventDefault and stopPropagation when can\'t go forward', () => {
|
|
125
|
-
base.index = 2;
|
|
126
|
-
base.forward(mockEvent);
|
|
127
|
-
expect(mockEvent.preventDefault).not.toHaveBeenCalled();
|
|
128
|
-
expect(mockEvent.stopPropagation).not.toHaveBeenCalled();
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
it('should not call preventDefault and stopPropagation when can\'t go backward', () => {
|
|
132
|
-
base.backward(mockEvent);
|
|
133
|
-
expect(mockEvent.preventDefault).not.toHaveBeenCalled();
|
|
134
|
-
expect(mockEvent.stopPropagation).not.toHaveBeenCalled();
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
it('should call onFocusChanged when focusing current index', () => {
|
|
138
|
-
base.focusCurrentIndex();
|
|
139
|
-
expect(base.props.onFocusChanged).toHaveBeenCalled();
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
it('should call onBeforeFocusChange when focusing current index', () => {
|
|
143
|
-
base.focusCurrentIndex();
|
|
144
|
-
expect(base.props.onBeforeFocusChange).toHaveBeenCalled();
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
it('should focus current index on focus', () => {
|
|
148
|
-
base.index = 2;
|
|
149
|
-
base.focus();
|
|
150
|
-
expect(refChildC.current!.focus).toHaveBeenCalled();
|
|
151
|
-
});
|
|
152
|
-
|
|
153
|
-
it('should call passed onKeyDown on onKeyDown', () => {
|
|
154
|
-
base.onKeyDown();
|
|
155
|
-
expect(mockKeydown).toHaveBeenCalled();
|
|
156
|
-
});
|
|
157
|
-
|
|
158
|
-
it('should throw in focusCurrentIndex when element does not implement focus', () => {
|
|
159
|
-
base.props.focusableChildren[2] = {};
|
|
160
|
-
base.index = 2;
|
|
161
|
-
expect(() => base.focusCurrentIndex()).toThrow();
|
|
162
|
-
});
|
|
163
|
-
|
|
164
|
-
it('should take result of hasDom into account of determining current focus position', () => {
|
|
165
|
-
base = new Base({
|
|
166
|
-
domRef: rootRef,
|
|
167
|
-
children: 'children',
|
|
168
|
-
focusableChildren: [refChildA, refChildB, refChildC, refChildD],
|
|
169
|
-
onFocusChanged: jest.fn(),
|
|
170
|
-
onBeforeFocusChange: jest.fn(),
|
|
171
|
-
});
|
|
172
|
-
((refChildD.current as IFocusable).hasDom as jest.MockedFn<
|
|
173
|
-
Exclude<IFocusable['hasDom'], undefined>
|
|
174
|
-
>).mockReturnValueOnce(true);
|
|
175
|
-
base.backward(mockEvent);
|
|
176
|
-
expect(base.index).toBe(2);
|
|
177
|
-
base.backward(mockEvent);
|
|
178
|
-
expect(base.index).toBe(1);
|
|
179
|
-
});
|
|
180
|
-
});
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import { isRtl } from '@24i/bigscreen-sdk/i18n';
|
|
2
|
-
import { Horizontal } from '../Horizontal';
|
|
3
|
-
import { rootRef, refChildA, refChildB, refChildC } from './shared';
|
|
4
|
-
|
|
5
|
-
jest.mock('@24i/bigscreen-sdk/i18n', () => ({
|
|
6
|
-
...jest.requireActual('@24i/bigscreen-sdk/i18n'),
|
|
7
|
-
isRtl: jest.fn().mockReturnValue(false),
|
|
8
|
-
}));
|
|
9
|
-
const isRtlMock = isRtl as jest.MockedFn<typeof isRtl>;
|
|
10
|
-
|
|
11
|
-
const mockEvent = {
|
|
12
|
-
target: false,
|
|
13
|
-
preventDefault: jest.fn(),
|
|
14
|
-
stopPropagation: jest.fn(),
|
|
15
|
-
};
|
|
16
|
-
const mockLEFTEvent = {
|
|
17
|
-
code: 'ArrowLeft',
|
|
18
|
-
...mockEvent,
|
|
19
|
-
};
|
|
20
|
-
const mockRIGHTEvent = {
|
|
21
|
-
code: 'ArrowRight',
|
|
22
|
-
...mockEvent,
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
describe('Horizontal Focus Layout', () => {
|
|
26
|
-
let horizontal: any;
|
|
27
|
-
beforeEach(() => {
|
|
28
|
-
horizontal = new Horizontal({
|
|
29
|
-
domRef: rootRef,
|
|
30
|
-
children: 'children',
|
|
31
|
-
focusableChildren: [refChildA, refChildB, refChildC],
|
|
32
|
-
onFocusChanged: jest.fn(),
|
|
33
|
-
onBeforeFocusChange: jest.fn(),
|
|
34
|
-
});
|
|
35
|
-
horizontal.forward = jest.fn();
|
|
36
|
-
horizontal.backward = jest.fn();
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
it('should be a class component', () => {
|
|
40
|
-
expect(Horizontal.isClass).toBe(true);
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
it('should call forward on RIGHT', () => {
|
|
44
|
-
horizontal.onKeyDown(mockRIGHTEvent);
|
|
45
|
-
expect(horizontal.forward).toHaveBeenCalled();
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
it('should call backward on LEFT', () => {
|
|
49
|
-
horizontal.setIndex(1);
|
|
50
|
-
horizontal.onKeyDown(mockLEFTEvent);
|
|
51
|
-
expect(horizontal.backward).toHaveBeenCalled();
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
it('should call backward on RIGHT when RTL', () => {
|
|
55
|
-
isRtlMock.mockReturnValueOnce(true);
|
|
56
|
-
horizontal.setIndex(1);
|
|
57
|
-
horizontal.onKeyDown(mockRIGHTEvent);
|
|
58
|
-
expect(horizontal.backward).toHaveBeenCalled();
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
it('should call forward on LEFT when RTL', () => {
|
|
62
|
-
isRtlMock.mockReturnValueOnce(true);
|
|
63
|
-
horizontal.onKeyDown(mockLEFTEvent);
|
|
64
|
-
expect(horizontal.forward).toHaveBeenCalled();
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
it('should call backward on RIGHT when forced RTL', () => {
|
|
68
|
-
horizontal.props.dir = 'rtl';
|
|
69
|
-
horizontal.setIndex(1);
|
|
70
|
-
horizontal.onKeyDown(mockRIGHTEvent);
|
|
71
|
-
expect(horizontal.backward).toHaveBeenCalled();
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
it('should call forward on LEFT when forced RTL', () => {
|
|
75
|
-
horizontal.props.dir = 'rtl';
|
|
76
|
-
horizontal.onKeyDown(mockLEFTEvent);
|
|
77
|
-
expect(horizontal.forward).toHaveBeenCalled();
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
it('should call backward on LEFT when RTL and forced LTR', () => {
|
|
81
|
-
isRtlMock.mockReturnValueOnce(true);
|
|
82
|
-
horizontal.props.dir = 'ltr';
|
|
83
|
-
horizontal.setIndex(1);
|
|
84
|
-
horizontal.onKeyDown(mockLEFTEvent);
|
|
85
|
-
expect(horizontal.backward).toHaveBeenCalled();
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
it('should call forward on RIGHT when RTL and forced LTR', () => {
|
|
89
|
-
isRtlMock.mockReturnValueOnce(true);
|
|
90
|
-
horizontal.props.dir = 'ltr';
|
|
91
|
-
horizontal.onKeyDown(mockRIGHTEvent);
|
|
92
|
-
expect(horizontal.forward).toHaveBeenCalled();
|
|
93
|
-
});
|
|
94
|
-
});
|
|
@@ -1,261 +0,0 @@
|
|
|
1
|
-
import { createRef } from '@24i/bigscreen-sdk/jsx';
|
|
2
|
-
import { LEFT, RIGHT, UP, DOWN, Key } from '@24i/bigscreen-sdk/device/keymap';
|
|
3
|
-
import { Matrix, CircularDirection } from '../Matrix';
|
|
4
|
-
|
|
5
|
-
const simulateKey = (key: Key): KeyboardEvent => ({
|
|
6
|
-
code: key.code,
|
|
7
|
-
preventDefault: jest.fn(),
|
|
8
|
-
stopPropagation: jest.fn(),
|
|
9
|
-
} as unknown as KeyboardEvent);
|
|
10
|
-
|
|
11
|
-
const getFocusable = () => ({
|
|
12
|
-
focus: jest.fn(),
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
const domRef = createRef(document.createElement('div'));
|
|
16
|
-
|
|
17
|
-
const A1 = createRef(getFocusable());
|
|
18
|
-
const A2 = createRef(getFocusable());
|
|
19
|
-
const A3 = createRef(getFocusable());
|
|
20
|
-
const B1 = createRef(getFocusable());
|
|
21
|
-
const C1 = createRef(getFocusable());
|
|
22
|
-
const C2 = createRef(getFocusable());
|
|
23
|
-
const C3 = createRef(getFocusable());
|
|
24
|
-
const D1 = createRef(getFocusable());
|
|
25
|
-
const D2 = createRef(getFocusable());
|
|
26
|
-
|
|
27
|
-
const MATRIX = [
|
|
28
|
-
[A1, B1, C1, D1],
|
|
29
|
-
[A2, B1, C2, C2],
|
|
30
|
-
[A3, B1, C3, D2],
|
|
31
|
-
];
|
|
32
|
-
|
|
33
|
-
describe('Matrix focus', () => {
|
|
34
|
-
let matrix: Matrix;
|
|
35
|
-
|
|
36
|
-
beforeEach(() => {
|
|
37
|
-
matrix = new Matrix({ ...Matrix.defaultProps, matrix: MATRIX, domRef, children: [] });
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
it('should have default index at 0, 0', () => {
|
|
41
|
-
expect(matrix.index).toStrictEqual({ x: 0, y: 0 });
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
it('should go A1 -> RIGHT -> B1', () => {
|
|
45
|
-
matrix.index = { x: 0, y: 0 };
|
|
46
|
-
const event = simulateKey(RIGHT);
|
|
47
|
-
matrix.onKeyDown(event);
|
|
48
|
-
expect(B1.current!.focus).toHaveBeenCalled();
|
|
49
|
-
expect(event.preventDefault).toHaveBeenCalled();
|
|
50
|
-
expect(event.stopPropagation).toHaveBeenCalled();
|
|
51
|
-
B1.current!.focus.mockClear();
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
it('should go A1 -> DOWN -> A2', () => {
|
|
55
|
-
matrix.index = { x: 0, y: 0 };
|
|
56
|
-
const event = simulateKey(DOWN);
|
|
57
|
-
matrix.onKeyDown(event);
|
|
58
|
-
expect(A2.current!.focus).toHaveBeenCalled();
|
|
59
|
-
expect(event.preventDefault).toHaveBeenCalled();
|
|
60
|
-
expect(event.stopPropagation).toHaveBeenCalled();
|
|
61
|
-
A2.current!.focus.mockClear();
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
it('should go D2 -> LEFT -> C3', () => {
|
|
65
|
-
matrix.index = { x: 3, y: 2 };
|
|
66
|
-
const event = simulateKey(LEFT);
|
|
67
|
-
matrix.onKeyDown(event);
|
|
68
|
-
expect(C3.current!.focus).toHaveBeenCalled();
|
|
69
|
-
expect(event.preventDefault).toHaveBeenCalled();
|
|
70
|
-
expect(event.stopPropagation).toHaveBeenCalled();
|
|
71
|
-
C3.current!.focus.mockClear();
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
it('should go D2 -> UP -> C2', () => {
|
|
75
|
-
matrix.index = { x: 3, y: 2 };
|
|
76
|
-
const event = simulateKey(UP);
|
|
77
|
-
matrix.onKeyDown(event);
|
|
78
|
-
expect(C2.current!.focus).toHaveBeenCalled();
|
|
79
|
-
expect(event.preventDefault).toHaveBeenCalled();
|
|
80
|
-
expect(event.stopPropagation).toHaveBeenCalled();
|
|
81
|
-
C2.current!.focus.mockClear();
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
it('should not leave left boundary', () => {
|
|
85
|
-
matrix.index = { x: 0, y: 0 };
|
|
86
|
-
const event = simulateKey(LEFT);
|
|
87
|
-
matrix.onKeyDown(event);
|
|
88
|
-
expect(matrix.index).toStrictEqual({ x: 0, y: 0 });
|
|
89
|
-
expect(event.preventDefault).not.toHaveBeenCalled();
|
|
90
|
-
expect(event.stopPropagation).not.toHaveBeenCalled();
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
it('should not leave top boundary', () => {
|
|
94
|
-
matrix.index = { x: 1, y: 2 };
|
|
95
|
-
const event = simulateKey(UP);
|
|
96
|
-
matrix.onKeyDown(event);
|
|
97
|
-
expect(matrix.index).toStrictEqual({ x: 1, y: 2 });
|
|
98
|
-
expect(event.preventDefault).not.toHaveBeenCalled();
|
|
99
|
-
expect(event.stopPropagation).not.toHaveBeenCalled();
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
it('should not leave right boundary', () => {
|
|
103
|
-
matrix.index = { x: 2, y: 1 };
|
|
104
|
-
const event = simulateKey(RIGHT);
|
|
105
|
-
matrix.onKeyDown(event);
|
|
106
|
-
expect(matrix.index).toStrictEqual({ x: 2, y: 1 });
|
|
107
|
-
expect(event.preventDefault).not.toHaveBeenCalled();
|
|
108
|
-
expect(event.stopPropagation).not.toHaveBeenCalled();
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
it('should not leave bottom boundary', () => {
|
|
112
|
-
matrix.index = { x: 3, y: 2 };
|
|
113
|
-
const event = simulateKey(DOWN);
|
|
114
|
-
matrix.onKeyDown(event);
|
|
115
|
-
expect(matrix.index).toStrictEqual({ x: 3, y: 2 });
|
|
116
|
-
expect(event.preventDefault).not.toHaveBeenCalled();
|
|
117
|
-
expect(event.stopPropagation).not.toHaveBeenCalled();
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
it('should keep row (Ax -> RIGHT -> B1 -> RIGHT -> Cx)', () => {
|
|
121
|
-
const event = simulateKey(RIGHT);
|
|
122
|
-
matrix.index = { x: 0, y: 0 };
|
|
123
|
-
matrix.onKeyDown(event);
|
|
124
|
-
matrix.onKeyDown(event);
|
|
125
|
-
expect(C1.current!.focus).toHaveBeenCalled();
|
|
126
|
-
matrix.index = { x: 0, y: 1 };
|
|
127
|
-
matrix.onKeyDown(event);
|
|
128
|
-
matrix.onKeyDown(event);
|
|
129
|
-
expect(C2.current!.focus).toHaveBeenCalled();
|
|
130
|
-
matrix.index = { x: 0, y: 2 };
|
|
131
|
-
matrix.onKeyDown(event);
|
|
132
|
-
matrix.onKeyDown(event);
|
|
133
|
-
expect(C3.current!.focus).toHaveBeenCalled();
|
|
134
|
-
C1.current!.focus.mockClear();
|
|
135
|
-
C2.current!.focus.mockClear();
|
|
136
|
-
C3.current!.focus.mockClear();
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
it('should keep column (C3/D2 -> UP -> C2 -> UP -> C1/D1)', () => {
|
|
140
|
-
const event = simulateKey(UP);
|
|
141
|
-
matrix.index = { x: 2, y: 2 };
|
|
142
|
-
matrix.onKeyDown(event);
|
|
143
|
-
matrix.onKeyDown(event);
|
|
144
|
-
expect(C1.current!.focus).toHaveBeenCalled();
|
|
145
|
-
matrix.index = { x: 3, y: 2 };
|
|
146
|
-
matrix.onKeyDown(event);
|
|
147
|
-
matrix.onKeyDown(event);
|
|
148
|
-
expect(D1.current!.focus).toHaveBeenCalled();
|
|
149
|
-
C1.current!.focus.mockClear();
|
|
150
|
-
D1.current!.focus.mockClear();
|
|
151
|
-
});
|
|
152
|
-
|
|
153
|
-
it('should skip same and focus next (C2 -> LEFT -> C2 -> B1)', () => {
|
|
154
|
-
matrix.index = { x: 3, y: 1 };
|
|
155
|
-
matrix.onKeyDown(simulateKey(LEFT));
|
|
156
|
-
expect(B1.current!.focus).toHaveBeenCalled();
|
|
157
|
-
B1.current!.focus.mockClear();
|
|
158
|
-
});
|
|
159
|
-
|
|
160
|
-
describe('circular focus', () => {
|
|
161
|
-
const commonProps = {
|
|
162
|
-
...Matrix.defaultProps,
|
|
163
|
-
matrix: MATRIX,
|
|
164
|
-
domRef,
|
|
165
|
-
children: null as any,
|
|
166
|
-
};
|
|
167
|
-
it('should circle to the left (A1 -> left -> D1)', () => {
|
|
168
|
-
matrix = new Matrix({ ...commonProps, circular: CircularDirection.HORIZONTAL });
|
|
169
|
-
matrix.index = { x: 0, y: 0 };
|
|
170
|
-
const event = simulateKey(LEFT);
|
|
171
|
-
matrix.onKeyDown(event);
|
|
172
|
-
expect(D1.current!.focus).toHaveBeenCalled();
|
|
173
|
-
expect(matrix.index).toEqual({ x: 3, y: 0 });
|
|
174
|
-
D1.current!.focus.mockClear();
|
|
175
|
-
});
|
|
176
|
-
|
|
177
|
-
it('should circle to the right (A1 -> right -> D1)', () => {
|
|
178
|
-
matrix = new Matrix({ ...commonProps, circular: CircularDirection.HORIZONTAL });
|
|
179
|
-
matrix.index = { x: 3, y: 0 };
|
|
180
|
-
const event = simulateKey(RIGHT);
|
|
181
|
-
matrix.onKeyDown(event);
|
|
182
|
-
expect(A1.current!.focus).toHaveBeenCalled();
|
|
183
|
-
expect(matrix.index).toEqual({ x: 0, y: 0 });
|
|
184
|
-
A1.current!.focus.mockClear();
|
|
185
|
-
});
|
|
186
|
-
|
|
187
|
-
it('should circle to upwards (A1 -> up -> A3)', () => {
|
|
188
|
-
matrix = new Matrix({ ...commonProps, circular: CircularDirection.VERTICAL });
|
|
189
|
-
matrix.index = { x: 0, y: 0 };
|
|
190
|
-
const event = simulateKey(UP);
|
|
191
|
-
matrix.onKeyDown(event);
|
|
192
|
-
expect(A3.current!.focus).toHaveBeenCalled();
|
|
193
|
-
expect(matrix.index).toEqual({ x: 0, y: 2 });
|
|
194
|
-
A3.current!.focus.mockClear();
|
|
195
|
-
});
|
|
196
|
-
|
|
197
|
-
it('should circle to downwards (A3 -> down -> A1)', () => {
|
|
198
|
-
matrix = new Matrix({ ...commonProps, circular: CircularDirection.VERTICAL });
|
|
199
|
-
matrix.index = { x: 0, y: 2 };
|
|
200
|
-
const event = simulateKey(DOWN);
|
|
201
|
-
matrix.onKeyDown(event);
|
|
202
|
-
expect(A1.current!.focus).toHaveBeenCalled();
|
|
203
|
-
expect(matrix.index).toEqual({ x: 0, y: 0 });
|
|
204
|
-
A1.current!.focus.mockClear();
|
|
205
|
-
});
|
|
206
|
-
|
|
207
|
-
it('should circle horizontally and vertically (A3 -> down -> A1 -> left -> D1)', () => {
|
|
208
|
-
matrix = new Matrix({ ...commonProps, circular: CircularDirection.ALL });
|
|
209
|
-
matrix.index = { x: 0, y: 2 };
|
|
210
|
-
let event = simulateKey(DOWN);
|
|
211
|
-
matrix.onKeyDown(event);
|
|
212
|
-
expect(matrix.index).toEqual({ x: 0, y: 0 });
|
|
213
|
-
|
|
214
|
-
event = simulateKey(LEFT);
|
|
215
|
-
matrix.onKeyDown(event);
|
|
216
|
-
expect(matrix.index).toEqual({ x: 3, y: 0 });
|
|
217
|
-
A1.current!.focus.mockClear();
|
|
218
|
-
D1.current!.focus.mockClear();
|
|
219
|
-
});
|
|
220
|
-
|
|
221
|
-
it('given vertical should not circle to horizontally (A1 -> left -> A1)', () => {
|
|
222
|
-
matrix = new Matrix({ ...commonProps, circular: CircularDirection.VERTICAL });
|
|
223
|
-
matrix.index = { x: 0, y: 0 };
|
|
224
|
-
const event = simulateKey(LEFT);
|
|
225
|
-
matrix.onKeyDown(event);
|
|
226
|
-
expect(matrix.index).toEqual({ x: 0, y: 0 });
|
|
227
|
-
});
|
|
228
|
-
|
|
229
|
-
it('given horizontal should not circle to vertically (A1 -> up -> A1)', () => {
|
|
230
|
-
matrix = new Matrix({ ...commonProps, circular: CircularDirection.HORIZONTAL });
|
|
231
|
-
matrix.index = { x: 0, y: 0 };
|
|
232
|
-
const event = simulateKey(UP);
|
|
233
|
-
matrix.onKeyDown(event);
|
|
234
|
-
expect(matrix.index).toEqual({ x: 0, y: 0 });
|
|
235
|
-
});
|
|
236
|
-
|
|
237
|
-
it('given 1 vertical key should not loop infinitely', () => {
|
|
238
|
-
matrix = new Matrix({ ...commonProps, circular: CircularDirection.VERTICAL });
|
|
239
|
-
matrix.index = { x: 1, y: 0 };
|
|
240
|
-
const event = simulateKey(UP);
|
|
241
|
-
matrix.onKeyDown(event);
|
|
242
|
-
expect(matrix.index).toEqual({ x: 1, y: 0 });
|
|
243
|
-
});
|
|
244
|
-
|
|
245
|
-
it('given 1 horizontal key should not loop infinitely', () => {
|
|
246
|
-
const keyMatrix = [
|
|
247
|
-
[A1, B1, C1, D1],
|
|
248
|
-
[C2, C2, C2, C2],
|
|
249
|
-
];
|
|
250
|
-
matrix = new Matrix({
|
|
251
|
-
...commonProps,
|
|
252
|
-
matrix: keyMatrix,
|
|
253
|
-
circular: CircularDirection.VERTICAL,
|
|
254
|
-
});
|
|
255
|
-
matrix.index = { x: 0, y: 1 };
|
|
256
|
-
const event = simulateKey(LEFT);
|
|
257
|
-
matrix.onKeyDown(event);
|
|
258
|
-
expect(matrix.index).toEqual({ x: 0, y: 1 });
|
|
259
|
-
});
|
|
260
|
-
});
|
|
261
|
-
});
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { Vertical } from '../Vertical';
|
|
2
|
-
import { rootRef, refChildA, refChildB, refChildC } from './shared';
|
|
3
|
-
|
|
4
|
-
const mockEvent = {
|
|
5
|
-
target: false,
|
|
6
|
-
preventDefault: jest.fn(),
|
|
7
|
-
stopPropagation: jest.fn(),
|
|
8
|
-
};
|
|
9
|
-
const mockUPEvent = {
|
|
10
|
-
code: 'ArrowUp',
|
|
11
|
-
...mockEvent,
|
|
12
|
-
};
|
|
13
|
-
const mockDOWNEvent = {
|
|
14
|
-
code: 'ArrowDown',
|
|
15
|
-
...mockEvent,
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
describe('Vertical Focus Layout', () => {
|
|
19
|
-
let vertical: any;
|
|
20
|
-
beforeEach(() => {
|
|
21
|
-
vertical = new Vertical({
|
|
22
|
-
domRef: rootRef,
|
|
23
|
-
children: 'children',
|
|
24
|
-
focusableChildren: [refChildA, refChildB, refChildC],
|
|
25
|
-
onFocusChanged: jest.fn(),
|
|
26
|
-
onBeforeFocusChange: jest.fn(),
|
|
27
|
-
});
|
|
28
|
-
vertical.forward = jest.fn();
|
|
29
|
-
vertical.backward = jest.fn();
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
it('should be a class component', () => {
|
|
33
|
-
expect(Vertical.isClass).toBe(true);
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
it('should call forward on DOWN', () => {
|
|
37
|
-
vertical.onKeyDown(mockDOWNEvent);
|
|
38
|
-
expect(vertical.forward).toHaveBeenCalled();
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
it('should call forward on UP', () => {
|
|
42
|
-
vertical.setIndex(1);
|
|
43
|
-
vertical.onKeyDown(mockUPEvent);
|
|
44
|
-
expect(vertical.backward).toHaveBeenCalled();
|
|
45
|
-
});
|
|
46
|
-
});
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import * as i18n from '@24i/bigscreen-sdk/i18n';
|
|
2
|
-
import { isRtl } from '../isRtl';
|
|
3
|
-
import { SharedProps } from '../types';
|
|
4
|
-
|
|
5
|
-
describe('isRtl', () => {
|
|
6
|
-
const mockIsRtl = jest.spyOn(i18n, 'isRtl');
|
|
7
|
-
|
|
8
|
-
it.each([
|
|
9
|
-
{ focusDir: 'ltr', langDir: 'ltr', expectedIsRtl: false },
|
|
10
|
-
{ focusDir: 'rtl', langDir: 'ltr', expectedIsRtl: true },
|
|
11
|
-
{ focusDir: 'auto', langDir: 'ltr', expectedIsRtl: false },
|
|
12
|
-
{ focusDir: undefined, langDir: 'ltr', expectedIsRtl: false },
|
|
13
|
-
{ focusDir: 'ltr', langDir: 'rtl', expectedIsRtl: false },
|
|
14
|
-
{ focusDir: 'rtl', langDir: 'rtl', expectedIsRtl: true },
|
|
15
|
-
{ focusDir: 'auto', langDir: 'rtl', expectedIsRtl: true },
|
|
16
|
-
{ focusDir: undefined, langDir: 'rtl', expectedIsRtl: true },
|
|
17
|
-
])('should for $focusDir focus and $langDir language return $expectedIsRtl', ({
|
|
18
|
-
focusDir, langDir, expectedIsRtl,
|
|
19
|
-
}) => {
|
|
20
|
-
mockIsRtl.mockReturnValue(langDir === 'rtl');
|
|
21
|
-
expect(isRtl(focusDir as SharedProps['dir'])).toBe(expectedIsRtl);
|
|
22
|
-
});
|
|
23
|
-
});
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { createRef } from '@24i/bigscreen-sdk/jsx';
|
|
2
|
-
import { IFocusable } from '../../IFocusable';
|
|
3
|
-
|
|
4
|
-
class ChildMock {
|
|
5
|
-
focus = jest.fn();
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
const root = document.createElement('div');
|
|
9
|
-
export const rootRef = createRef(root);
|
|
10
|
-
|
|
11
|
-
const childA = new ChildMock();
|
|
12
|
-
const childB = new ChildMock();
|
|
13
|
-
const childC = new ChildMock();
|
|
14
|
-
const childD = new ChildMock();
|
|
15
|
-
(childD as IFocusable).hasDom = jest.fn().mockReturnValue(false);
|
|
16
|
-
export const refChildA = createRef(childA);
|
|
17
|
-
export const refChildB = createRef(childB);
|
|
18
|
-
export const refChildC = createRef(childC);
|
|
19
|
-
export const refChildD = createRef(childD);
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-magic-numbers */
|
|
2
|
-
import { KeyMatrixCell } from '../types';
|
|
3
|
-
|
|
4
|
-
/* eslint-disable max-len */
|
|
5
|
-
export const makeNormalFocusStrings = (layout: KeyMatrixCell[][]) => [
|
|
6
|
-
['', '', ...layout[0], 'backspace', 'backspace'],
|
|
7
|
-
['abc', 'abc', ...layout[1], 'clear', 'clear'],
|
|
8
|
-
['special', 'special', ...layout[2], 'left', 'right'],
|
|
9
|
-
['', '', ...layout[3], '', ''],
|
|
10
|
-
['', '', 'shift', 'shift', 'space', 'space', 'space', 'space', 'space', 'space', 'domain', 'domain', 'continue', 'continue'],
|
|
11
|
-
];
|
|
12
|
-
|
|
13
|
-
export const makeSpecialFocusStrings = (layout: KeyMatrixCell[][]) => [
|
|
14
|
-
['', '', ...layout[0], 'backspace', 'backspace'],
|
|
15
|
-
['abc', 'abc', ...layout[1], 'clear', 'clear'],
|
|
16
|
-
['special', 'special', ...layout[2], 'left', 'right'],
|
|
17
|
-
['', '', ...layout[3], '', ''],
|
|
18
|
-
['', '', ...layout[4], 'space', 'space', 'space', 'space', 'space', 'space', ...layout[5], 'continue', 'continue'],
|
|
19
|
-
];
|