@sap-ux/control-property-editor 0.8.1 → 1.0.1
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/CHANGELOG.md +39 -0
- package/dist/app.css +1 -1
- package/dist/app.css.map +3 -3
- package/dist/app.js +54 -85
- package/dist/app.js.map +4 -4
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/{esbuild.js → esbuild.mjs} +7 -10
- package/{eslint.config.js → eslint.config.mjs} +4 -2
- package/jest.config.mjs +39 -0
- package/package.json +8 -6
- package/src/App.tsx +8 -8
- package/src/actions.ts +1 -1
- package/src/components/ChangeIndicator.tsx +1 -1
- package/src/components/ThemeSelectorCallout.tsx +3 -3
- package/src/components/index.ts +3 -3
- package/src/i18n.ts +1 -1
- package/src/index.tsx +5 -5
- package/src/middleware.ts +2 -2
- package/src/panels/LeftPanel.tsx +2 -2
- package/src/panels/RightPanel.tsx +4 -4
- package/src/panels/changes/ChangeStack.tsx +10 -10
- package/src/panels/changes/ChangeStackHeader.tsx +1 -1
- package/src/panels/changes/ChangesPanel.tsx +9 -9
- package/src/panels/changes/ControlChange.tsx +1 -1
- package/src/panels/changes/DisplayAsIcon.tsx +2 -2
- package/src/panels/changes/GenericChange.tsx +3 -3
- package/src/panels/changes/GenericGroup.tsx +1 -1
- package/src/panels/changes/UnknownChange.tsx +1 -1
- package/src/panels/changes/index.tsx +2 -2
- package/src/panels/changes/utils.ts +1 -1
- package/src/panels/index.ts +2 -2
- package/src/panels/info-center/InfoCenter.tsx +4 -4
- package/src/panels/info-center/InfoMessageItem.tsx +2 -2
- package/src/panels/info-center/index.ts +1 -1
- package/src/panels/outline/Funnel.tsx +4 -4
- package/src/panels/outline/OutlinePanel.tsx +3 -3
- package/src/panels/outline/Tree.tsx +6 -6
- package/src/panels/outline/index.ts +1 -1
- package/src/panels/outline/utils.ts +2 -2
- package/src/panels/properties/Clipboard.tsx +1 -1
- package/src/panels/properties/DropdownEditor.tsx +4 -4
- package/src/panels/properties/Funnel.tsx +4 -4
- package/src/panels/properties/HeaderField.tsx +3 -3
- package/src/panels/properties/IconValueHelp.tsx +3 -3
- package/src/panels/properties/InputTypeSelector.tsx +2 -2
- package/src/panels/properties/InputTypeToggle.tsx +5 -5
- package/src/panels/properties/InputTypeWrapper.tsx +8 -8
- package/src/panels/properties/PropertiesList.tsx +14 -14
- package/src/panels/properties/PropertyDocumentation.tsx +2 -2
- package/src/panels/properties/StringEditor.tsx +6 -6
- package/src/panels/properties/index.ts +1 -1
- package/src/panels/properties/propertyValuesCache.ts +1 -1
- package/src/panels/properties/types.ts +1 -1
- package/src/panels/quick-actions/NestedQuickAction.tsx +2 -2
- package/src/panels/quick-actions/QuickActionList.tsx +4 -4
- package/src/panels/quick-actions/SimpleQuickAction.tsx +1 -1
- package/src/panels/quick-actions/index.ts +1 -1
- package/src/slice.ts +1 -1
- package/src/store.ts +3 -3
- package/src/toolbar/DeviceSelector.tsx +3 -3
- package/src/toolbar/DeviceToggle.tsx +3 -3
- package/src/toolbar/ModeSwitcher.tsx +1 -1
- package/src/toolbar/ToolBar.tsx +6 -6
- package/src/toolbar/UndoRedoSaveActions.tsx +4 -4
- package/src/toolbar/ViewChanger.tsx +2 -2
- package/src/toolbar/index.ts +1 -1
- package/src/use-theme.ts +1 -1
- package/src/ws-middleware.ts +3 -3
- package/test/unit/App.test.tsx +3 -1
- package/test/unit/appIndex.test.ts +37 -19
- package/test/unit/middleware.test.ts +39 -73
- package/test/unit/panels/changes/ChangesPanel.test.tsx +3 -15
- package/test/unit/panels/changes/FileChange.test.tsx +2 -10
- package/test/unit/panels/properties/DropdownEditor.test.tsx +0 -2
- package/test/unit/panels/properties/InputTypeToggle.test.tsx +8 -9
- package/test/unit/setup.ts +18 -2
- package/test/utils/utils.tsx +2 -0
- package/tsconfig.eslint.json +2 -1
- package/tsconfig.json +4 -5
- package/jest.config.js +0 -21
|
@@ -24,15 +24,15 @@ import {
|
|
|
24
24
|
STRING_VALUE_TYPE
|
|
25
25
|
} from '@sap-ux-private/control-property-editor-common';
|
|
26
26
|
|
|
27
|
-
import { IconName } from '../../icons';
|
|
28
|
-
import { ChangeIndicator } from '../../components/ChangeIndicator';
|
|
27
|
+
import { IconName } from '../../icons.js';
|
|
28
|
+
import { ChangeIndicator } from '../../components/ChangeIndicator.js';
|
|
29
29
|
|
|
30
|
-
import type { CacheValue } from './propertyValuesCache';
|
|
31
|
-
import type { InputTypeToggleOptionProps, InputTypeWrapperProps } from './types';
|
|
32
|
-
import { InputType, isExpression } from './types';
|
|
33
|
-
import { PropertyDocumentation } from './PropertyDocumentation';
|
|
34
|
-
import { defaultFontSize } from './constants';
|
|
35
|
-
import { InputTypeSelector } from './InputTypeSelector';
|
|
30
|
+
import type { CacheValue } from './propertyValuesCache.js';
|
|
31
|
+
import type { InputTypeToggleOptionProps, InputTypeWrapperProps } from './types.js';
|
|
32
|
+
import { InputType, isExpression } from './types.js';
|
|
33
|
+
import { PropertyDocumentation } from './PropertyDocumentation.js';
|
|
34
|
+
import { defaultFontSize } from './constants.js';
|
|
35
|
+
import { InputTypeSelector } from './InputTypeSelector.js';
|
|
36
36
|
import { useTranslation } from 'react-i18next';
|
|
37
37
|
|
|
38
38
|
export const getDefaultInputType = (editor: string, type: string, value: CacheValue): InputType => {
|
|
@@ -7,24 +7,24 @@ import {
|
|
|
7
7
|
DROPDOWN_EDITOR_TYPE,
|
|
8
8
|
INPUT_EDITOR_TYPE
|
|
9
9
|
} from '@sap-ux-private/control-property-editor-common';
|
|
10
|
-
import { Separator } from '../../components/Separator';
|
|
11
|
-
import type { RootState } from '../../store';
|
|
12
|
-
import { DropdownEditor } from './DropdownEditor';
|
|
13
|
-
import { HeaderField } from './HeaderField';
|
|
14
|
-
import { getDefaultInputType, getInputTypeToggleOptions, InputTypeWrapper } from './InputTypeWrapper';
|
|
15
|
-
import { setCachedValue } from './propertyValuesCache';
|
|
16
|
-
import { StringEditor } from './StringEditor';
|
|
17
|
-
import type { InputTypeWrapperProps } from './types';
|
|
18
|
-
import { isExpression } from './types';
|
|
19
|
-
import { sectionHeaderFontSize } from './constants';
|
|
10
|
+
import { Separator } from '../../components/Separator.js';
|
|
11
|
+
import type { RootState } from '../../store.js';
|
|
12
|
+
import { DropdownEditor } from './DropdownEditor.js';
|
|
13
|
+
import { HeaderField } from './HeaderField.js';
|
|
14
|
+
import { getDefaultInputType, getInputTypeToggleOptions, InputTypeWrapper } from './InputTypeWrapper.js';
|
|
15
|
+
import { setCachedValue } from './propertyValuesCache.js';
|
|
16
|
+
import { StringEditor } from './StringEditor.js';
|
|
17
|
+
import type { InputTypeWrapperProps } from './types.js';
|
|
18
|
+
import { isExpression } from './types.js';
|
|
19
|
+
import { sectionHeaderFontSize } from './constants.js';
|
|
20
20
|
import { useSelector } from 'react-redux';
|
|
21
21
|
import { UISearchBox } from '@sap-ux/ui-components';
|
|
22
|
-
import { NoControlSelected } from './NoControlSelected';
|
|
22
|
+
import { NoControlSelected } from './NoControlSelected.js';
|
|
23
23
|
import { Label } from '@fluentui/react';
|
|
24
24
|
import './Properties.scss';
|
|
25
|
-
import { Funnel } from './Funnel';
|
|
26
|
-
import type { ControlChangeStats, FilterOptions } from '../../slice';
|
|
27
|
-
import { FilterName } from '../../slice';
|
|
25
|
+
import { Funnel } from './Funnel.js';
|
|
26
|
+
import type { ControlChangeStats, FilterOptions } from '../../slice.js';
|
|
27
|
+
import { FilterName } from '../../slice.js';
|
|
28
28
|
|
|
29
29
|
/**
|
|
30
30
|
* React element for all properties including id & type and property editors.
|
|
@@ -7,8 +7,8 @@ import { Text, Stack } from '@fluentui/react';
|
|
|
7
7
|
import { UIIcon, UIIconButton, UiIcons } from '@sap-ux/ui-components';
|
|
8
8
|
|
|
9
9
|
import type { Control, SavedGenericChange, PendingGenericChange } from '@sap-ux-private/control-property-editor-common';
|
|
10
|
-
import { Separator } from '../../components';
|
|
11
|
-
import type { RootState } from '../../store';
|
|
10
|
+
import { Separator } from '../../components/index.js';
|
|
11
|
+
import type { RootState } from '../../store.js';
|
|
12
12
|
|
|
13
13
|
import styles from './PropertyDocumentation.module.scss';
|
|
14
14
|
|
|
@@ -5,18 +5,18 @@ import { useDispatch, useSelector } from 'react-redux';
|
|
|
5
5
|
import type { UITextInputProps } from '@sap-ux/ui-components';
|
|
6
6
|
import { UITextInput } from '@sap-ux/ui-components';
|
|
7
7
|
|
|
8
|
-
import { changeProperty } from '../../slice';
|
|
8
|
+
import { changeProperty } from '../../slice.js';
|
|
9
9
|
|
|
10
|
-
import type { PropertyInputProps } from './types';
|
|
11
|
-
import { isExpression, InputType } from './types';
|
|
12
|
-
import { setCachedValue } from './propertyValuesCache';
|
|
10
|
+
import type { PropertyInputProps } from './types.js';
|
|
11
|
+
import { isExpression, InputType } from './types.js';
|
|
12
|
+
import { setCachedValue } from './propertyValuesCache.js';
|
|
13
13
|
|
|
14
14
|
import './Properties.scss';
|
|
15
15
|
import { reportTelemetry, FLOAT_VALUE_TYPE, INTEGER_VALUE_TYPE } from '@sap-ux-private/control-property-editor-common';
|
|
16
16
|
import './SapUiIcon.scss';
|
|
17
|
-
import { IconValueHelp } from './IconValueHelp';
|
|
17
|
+
import { IconValueHelp } from './IconValueHelp.js';
|
|
18
18
|
import type { IconDetails } from '@sap-ux-private/control-property-editor-common';
|
|
19
|
-
import type { RootState } from '../../store';
|
|
19
|
+
import type { RootState } from '../../store.js';
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
22
|
* React element for string editor in property panel.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { PropertiesList } from './PropertiesList';
|
|
1
|
+
export { PropertiesList } from './PropertiesList.js';
|
|
@@ -7,7 +7,7 @@ import type {
|
|
|
7
7
|
INPUT_EDITOR_TYPE
|
|
8
8
|
} from '@sap-ux-private/control-property-editor-common';
|
|
9
9
|
|
|
10
|
-
import type { PropertyChangeStats } from '../../slice';
|
|
10
|
+
import type { PropertyChangeStats } from '../../slice.js';
|
|
11
11
|
|
|
12
12
|
export interface PropertyInputProps<T extends ControlProperty = ControlProperty> {
|
|
13
13
|
controlId: string;
|
|
@@ -7,8 +7,8 @@ import { UIDirectionalHint, UIIcon, UILink, UIContextualMenu, UIContextualMenuLa
|
|
|
7
7
|
|
|
8
8
|
import type { NestedQuickAction, NestedQuickActionChild } from '@sap-ux-private/control-property-editor-common';
|
|
9
9
|
import { executeQuickAction } from '@sap-ux-private/control-property-editor-common';
|
|
10
|
-
import { IconName } from '../../icons';
|
|
11
|
-
import type { RootState } from '../../store';
|
|
10
|
+
import { IconName } from '../../icons.js';
|
|
11
|
+
import type { RootState } from '../../store.js';
|
|
12
12
|
|
|
13
13
|
export interface NestedQuickActionListItemProps {
|
|
14
14
|
action: Readonly<NestedQuickAction>;
|
|
@@ -7,11 +7,11 @@ import { useSelector } from 'react-redux';
|
|
|
7
7
|
import type { QuickActionGroup } from '@sap-ux-private/control-property-editor-common';
|
|
8
8
|
import { NESTED_QUICK_ACTION_KIND, SIMPLE_QUICK_ACTION_KIND } from '@sap-ux-private/control-property-editor-common';
|
|
9
9
|
|
|
10
|
-
import type { RootState } from '../../store';
|
|
11
|
-
import { sectionHeaderFontSize } from '../properties/constants';
|
|
10
|
+
import type { RootState } from '../../store.js';
|
|
11
|
+
import { sectionHeaderFontSize } from '../properties/constants.js';
|
|
12
12
|
|
|
13
|
-
import { SimpleQuickActionListItem } from './SimpleQuickAction';
|
|
14
|
-
import { NestedQuickActionListItem } from './NestedQuickAction';
|
|
13
|
+
import { SimpleQuickActionListItem } from './SimpleQuickAction.js';
|
|
14
|
+
import { NestedQuickActionListItem } from './NestedQuickAction.js';
|
|
15
15
|
|
|
16
16
|
import './QuickAction.scss';
|
|
17
17
|
|
|
@@ -7,7 +7,7 @@ import { UILink } from '@sap-ux/ui-components';
|
|
|
7
7
|
import type { SimpleQuickAction } from '@sap-ux-private/control-property-editor-common';
|
|
8
8
|
import { executeQuickAction } from '@sap-ux-private/control-property-editor-common';
|
|
9
9
|
|
|
10
|
-
import type { RootState } from '../../store';
|
|
10
|
+
import type { RootState } from '../../store.js';
|
|
11
11
|
|
|
12
12
|
export interface SimpleQuickActionListItemProps {
|
|
13
13
|
action: Readonly<SimpleQuickAction>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { QuickActionList } from './QuickActionList';
|
|
1
|
+
export { QuickActionList } from './QuickActionList.js';
|
package/src/slice.ts
CHANGED
|
@@ -45,7 +45,7 @@ import {
|
|
|
45
45
|
GENERIC_CHANGE_KIND,
|
|
46
46
|
toggleAppPreviewVisibility
|
|
47
47
|
} from '@sap-ux-private/control-property-editor-common';
|
|
48
|
-
import { DeviceType } from './devices';
|
|
48
|
+
import { DeviceType } from './devices.js';
|
|
49
49
|
|
|
50
50
|
export interface SliceState {
|
|
51
51
|
deviceType: DeviceType;
|
package/src/store.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { configureStore, compose, applyMiddleware } from '@reduxjs/toolkit';
|
|
2
2
|
import { useDispatch } from 'react-redux';
|
|
3
|
-
import { communicationMiddleware } from './middleware';
|
|
4
|
-
import reducer from './slice';
|
|
5
|
-
import { webSocketMiddleware } from './ws-middleware';
|
|
3
|
+
import { communicationMiddleware } from './middleware.js';
|
|
4
|
+
import reducer from './slice.js';
|
|
5
|
+
import { webSocketMiddleware } from './ws-middleware.js';
|
|
6
6
|
|
|
7
7
|
declare let window: Window & { __REDUX_DEVTOOLS_EXTENSION_COMPOSE__: <R>(data: R) => R };
|
|
8
8
|
const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ ?? compose;
|
|
@@ -2,10 +2,10 @@ import type { ReactElement } from 'react';
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { useTranslation } from 'react-i18next';
|
|
4
4
|
|
|
5
|
-
import { DeviceType } from '../devices';
|
|
5
|
+
import { DeviceType } from '../devices.js';
|
|
6
6
|
|
|
7
|
-
import type { DeviceToggleProps } from './DeviceToggle';
|
|
8
|
-
import { DeviceToggle } from './DeviceToggle';
|
|
7
|
+
import type { DeviceToggleProps } from './DeviceToggle.js';
|
|
8
|
+
import { DeviceToggle } from './DeviceToggle.js';
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* React element for Device Selector.
|
|
@@ -4,9 +4,9 @@ import { useDispatch, useSelector } from 'react-redux';
|
|
|
4
4
|
import type { AnyAction } from 'redux';
|
|
5
5
|
import { UIIconButton } from '@sap-ux/ui-components';
|
|
6
6
|
|
|
7
|
-
import type { DeviceType } from '../devices';
|
|
8
|
-
import { changeDeviceType } from '../slice';
|
|
9
|
-
import type { RootState } from '../store';
|
|
7
|
+
import type { DeviceType } from '../devices.js';
|
|
8
|
+
import { changeDeviceType } from '../slice.js';
|
|
9
|
+
import type { RootState } from '../store.js';
|
|
10
10
|
|
|
11
11
|
export interface DeviceToggleProps {
|
|
12
12
|
deviceType: DeviceType;
|
|
@@ -6,7 +6,7 @@ import { useDispatch, useSelector } from 'react-redux';
|
|
|
6
6
|
import { setAppMode } from '@sap-ux-private/control-property-editor-common';
|
|
7
7
|
import { UIDefaultButton, UILabel } from '@sap-ux/ui-components';
|
|
8
8
|
|
|
9
|
-
import type { RootState } from '../store';
|
|
9
|
+
import type { RootState } from '../store.js';
|
|
10
10
|
|
|
11
11
|
import './ModeSwitcher.scss';
|
|
12
12
|
|
package/src/toolbar/ToolBar.tsx
CHANGED
|
@@ -6,13 +6,13 @@ import { useSelector } from 'react-redux';
|
|
|
6
6
|
import { UIFocusZone, UILabel, UIToolbar, UIToolbarColumn } from '@sap-ux/ui-components';
|
|
7
7
|
import type { Scenario } from '@sap-ux-private/control-property-editor-common';
|
|
8
8
|
|
|
9
|
-
import type { RootState } from '../store';
|
|
10
|
-
import { Separator, ThemeSelectorCallout } from '../components';
|
|
9
|
+
import type { RootState } from '../store.js';
|
|
10
|
+
import { Separator, ThemeSelectorCallout } from '../components/index.js';
|
|
11
11
|
|
|
12
|
-
import { ViewChanger } from './ViewChanger';
|
|
13
|
-
import { DeviceSelector } from './DeviceSelector';
|
|
14
|
-
import { ModeSwitcher } from './ModeSwitcher';
|
|
15
|
-
import { UndoRedoSaveActions } from './UndoRedoSaveActions';
|
|
12
|
+
import { ViewChanger } from './ViewChanger.js';
|
|
13
|
+
import { DeviceSelector } from './DeviceSelector.js';
|
|
14
|
+
import { ModeSwitcher } from './ModeSwitcher.js';
|
|
15
|
+
import { UndoRedoSaveActions } from './UndoRedoSaveActions.js';
|
|
16
16
|
|
|
17
17
|
import './ToolBar.scss';
|
|
18
18
|
|
|
@@ -6,10 +6,10 @@ import { useTranslation } from 'react-i18next';
|
|
|
6
6
|
import { redo, reloadApplication, save, undo } from '@sap-ux-private/control-property-editor-common';
|
|
7
7
|
import { UIIconButton, UiIcons } from '@sap-ux/ui-components';
|
|
8
8
|
|
|
9
|
-
import type { ChangesSlice } from '../slice';
|
|
10
|
-
import type { RootState } from '../store';
|
|
11
|
-
import { Separator } from '../components';
|
|
12
|
-
import { IconName } from '../icons';
|
|
9
|
+
import type { ChangesSlice } from '../slice.js';
|
|
10
|
+
import type { RootState } from '../store.js';
|
|
11
|
+
import { Separator } from '../components/index.js';
|
|
12
|
+
import { IconName } from '../icons.js';
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* React element for Undo, Redo and Save.
|
|
@@ -6,8 +6,8 @@ import { useDispatch, useSelector } from 'react-redux';
|
|
|
6
6
|
import type { UIComboBoxOption, UIComboBoxRef } from '@sap-ux/ui-components';
|
|
7
7
|
import { UIComboBox, UIIconButton, UiIcons } from '@sap-ux/ui-components';
|
|
8
8
|
|
|
9
|
-
import type { RootState } from '../store';
|
|
10
|
-
import { changePreviewScale, changePreviewScaleMode } from '../slice';
|
|
9
|
+
import type { RootState } from '../store.js';
|
|
10
|
+
import { changePreviewScale, changePreviewScaleMode } from '../slice.js';
|
|
11
11
|
|
|
12
12
|
import styles from './ViewChanger.module.scss';
|
|
13
13
|
|
package/src/toolbar/index.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './ToolBar';
|
|
1
|
+
export * from './ToolBar.js';
|
package/src/use-theme.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type React from 'react';
|
|
2
2
|
import { useEffect } from 'react';
|
|
3
|
-
import { useLocalStorage } from './use-local-storage';
|
|
3
|
+
import { useLocalStorage } from './use-local-storage.js';
|
|
4
4
|
|
|
5
5
|
export type ThemeName = 'dark modern' | 'light modern' | 'high contrast black';
|
|
6
6
|
/**
|
package/src/ws-middleware.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { AnyAction, Dispatch } from 'redux';
|
|
2
2
|
import type { Middleware, MiddlewareAPI } from '@reduxjs/toolkit';
|
|
3
3
|
|
|
4
|
-
import type { Action } from './actions';
|
|
5
|
-
import type reducer from './slice';
|
|
6
|
-
import { fileChanged, initializeLivereload } from './slice';
|
|
4
|
+
import type { Action } from './actions.js';
|
|
5
|
+
import type reducer from './slice.js';
|
|
6
|
+
import { fileChanged, initializeLivereload } from './slice.js';
|
|
7
7
|
import { externalFileChange } from '@sap-ux-private/control-property-editor-common';
|
|
8
8
|
|
|
9
9
|
/**
|
package/test/unit/App.test.tsx
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import { jest } from '@jest/globals';
|
|
1
2
|
import React from 'react';
|
|
2
3
|
import { fireEvent, screen } from '@testing-library/react';
|
|
3
|
-
import
|
|
4
|
+
import reactDomTestUtils from 'react-dom/test-utils';
|
|
5
|
+
const { act } = reactDomTestUtils;
|
|
4
6
|
|
|
5
7
|
import { render, mockDomEventListener } from './utils';
|
|
6
8
|
|
|
@@ -1,19 +1,37 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import * as
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { jest } from '@jest/globals';
|
|
2
|
+
import * as actualUiComponents from '@sap-ux/ui-components';
|
|
3
|
+
|
|
4
|
+
const mockInitI18n = jest.fn();
|
|
5
|
+
const mockRegisterAppIcons = jest.fn();
|
|
6
|
+
const mockInitIcons = jest.fn();
|
|
7
|
+
const mockInitTheme = jest.fn();
|
|
8
|
+
const mockReactDOMRender = jest.fn();
|
|
9
|
+
|
|
10
|
+
jest.unstable_mockModule('../../src/i18n', () => ({
|
|
11
|
+
initI18n: mockInitI18n
|
|
12
|
+
}));
|
|
13
|
+
|
|
14
|
+
jest.unstable_mockModule('../../src/icons', () => ({
|
|
15
|
+
registerAppIcons: mockRegisterAppIcons,
|
|
16
|
+
IconName: {}
|
|
17
|
+
}));
|
|
18
|
+
|
|
19
|
+
jest.unstable_mockModule('@sap-ux/ui-components', () => ({
|
|
20
|
+
...actualUiComponents,
|
|
21
|
+
initIcons: mockInitIcons,
|
|
22
|
+
initTheme: mockInitTheme
|
|
23
|
+
}));
|
|
24
|
+
|
|
25
|
+
jest.unstable_mockModule('react-dom', () => ({
|
|
26
|
+
default: { render: mockReactDOMRender },
|
|
27
|
+
render: mockReactDOMRender
|
|
28
|
+
}));
|
|
29
|
+
|
|
30
|
+
const { start } = await import('../../src/index');
|
|
31
|
+
const { store } = await import('../../src/store');
|
|
32
|
+
const { initializeLivereload, setFeatureToggles, setProjectScenario } = await import('../../src/slice');
|
|
9
33
|
|
|
10
34
|
describe('index', () => {
|
|
11
|
-
const i18nSpy = jest.spyOn(i18n, 'initI18n');
|
|
12
|
-
const iconsSpy = jest.spyOn(icons, 'registerAppIcons');
|
|
13
|
-
// ts-ignore
|
|
14
|
-
const initIconSpy = jest.spyOn(initIcon, 'initIcons');
|
|
15
|
-
const initThemeSpy = jest.spyOn(initTheme, 'initTheme');
|
|
16
|
-
const reactSpy = jest.spyOn(ReactDOM, 'render').mockReturnValue();
|
|
17
35
|
const dispatchSpy = jest.spyOn(store, 'dispatch');
|
|
18
36
|
|
|
19
37
|
test('start', () => {
|
|
@@ -26,11 +44,11 @@ describe('index', () => {
|
|
|
26
44
|
}
|
|
27
45
|
];
|
|
28
46
|
start({ previewUrl, rootElementId, livereloadPort: 8080, scenario: 'APP_VARIANT', features });
|
|
29
|
-
expect(
|
|
30
|
-
expect(
|
|
31
|
-
expect(
|
|
32
|
-
expect(
|
|
33
|
-
expect(
|
|
47
|
+
expect(mockInitI18n).toHaveBeenCalledTimes(1);
|
|
48
|
+
expect(mockRegisterAppIcons).toHaveBeenCalledTimes(1);
|
|
49
|
+
expect(mockInitIcons).toHaveBeenCalledTimes(1);
|
|
50
|
+
expect(mockInitTheme).toHaveBeenCalledTimes(1);
|
|
51
|
+
expect(mockReactDOMRender).toHaveBeenCalledTimes(1);
|
|
34
52
|
expect(dispatchSpy).toHaveBeenCalledTimes(3);
|
|
35
53
|
expect(dispatchSpy).toHaveBeenNthCalledWith(1, setFeatureToggles(features));
|
|
36
54
|
expect(dispatchSpy).toHaveBeenNthCalledWith(2, setProjectScenario('APP_VARIANT'));
|