@sap-ux/control-property-editor 0.8.0 → 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 +45 -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.module.scss +2 -1
- package/src/panels/changes/ChangesPanel.tsx +16 -15
- 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.scss +2 -1
- 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.scss +2 -1
- 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/Properties.scss +2 -1
- package/src/panels/properties/PropertiesList.tsx +15 -16
- 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
|
@@ -1,22 +1,30 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { jest } from '@jest/globals';
|
|
2
|
+
import * as actualCommon from '@sap-ux-private/control-property-editor-common';
|
|
3
|
+
|
|
4
|
+
const mockSendAction = jest.fn();
|
|
5
|
+
const mockDispose = jest.fn();
|
|
6
|
+
const mockStartPostMessageCommunication = jest.fn().mockReturnValue({
|
|
7
|
+
sendAction: mockSendAction,
|
|
8
|
+
dispose: mockDispose
|
|
7
9
|
});
|
|
8
10
|
|
|
11
|
+
jest.unstable_mockModule('@sap-ux-private/control-property-editor-common', () => ({
|
|
12
|
+
...actualCommon,
|
|
13
|
+
startPostMessageCommunication: mockStartPostMessageCommunication
|
|
14
|
+
}));
|
|
15
|
+
|
|
16
|
+
jest.unstable_mockModule('../../src/slice', () => ({
|
|
17
|
+
changeProperty: { type: '[ext] property-changed' }
|
|
18
|
+
}));
|
|
19
|
+
|
|
20
|
+
const common = await import('@sap-ux-private/control-property-editor-common');
|
|
21
|
+
const { communicationMiddleware } = await import('../../src/middleware');
|
|
22
|
+
|
|
9
23
|
describe('communication middleware', () => {
|
|
10
|
-
let
|
|
11
|
-
let dispatch: jest.SpyInstance;
|
|
24
|
+
let dispatch: jest.Mock;
|
|
12
25
|
let middleWare: any;
|
|
13
|
-
const sendActionfn = jest.fn();
|
|
14
26
|
|
|
15
27
|
beforeEach(() => {
|
|
16
|
-
messageProcessor = jest.spyOn(common, 'startPostMessageCommunication').mockReturnValue({
|
|
17
|
-
sendAction: sendActionfn,
|
|
18
|
-
dispose: jest.fn()
|
|
19
|
-
});
|
|
20
28
|
dispatch = jest.fn();
|
|
21
29
|
middleWare = communicationMiddleware({
|
|
22
30
|
dispatch,
|
|
@@ -27,10 +35,8 @@ describe('communication middleware', () => {
|
|
|
27
35
|
} as any);
|
|
28
36
|
});
|
|
29
37
|
afterEach(() => {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
sendActionfn.mockReset();
|
|
38
|
+
mockStartPostMessageCommunication.mockClear();
|
|
39
|
+
mockSendAction.mockReset();
|
|
34
40
|
});
|
|
35
41
|
|
|
36
42
|
test('property changed in UI5 application', () => {
|
|
@@ -39,15 +45,15 @@ describe('communication middleware', () => {
|
|
|
39
45
|
propertyName: 'text',
|
|
40
46
|
newValue: 'new value'
|
|
41
47
|
});
|
|
42
|
-
|
|
48
|
+
mockStartPostMessageCommunication.mock.calls[0][1](action);
|
|
43
49
|
expect(dispatch).toHaveBeenCalledTimes(1);
|
|
44
50
|
expect(dispatch).toHaveBeenNthCalledWith(1, action);
|
|
45
51
|
});
|
|
46
52
|
|
|
47
53
|
test('select control in UI5 application on apploaded', () => {
|
|
48
54
|
const action = common.appLoaded();
|
|
49
|
-
|
|
50
|
-
expect(
|
|
55
|
+
mockStartPostMessageCommunication.mock.calls[0][1](action);
|
|
56
|
+
expect(mockSendAction).toHaveBeenCalledWith(common.selectControl('filterBar'));
|
|
51
57
|
expect(dispatch).toHaveBeenCalledTimes(1);
|
|
52
58
|
expect(dispatch).toHaveBeenNthCalledWith(1, action);
|
|
53
59
|
});
|
|
@@ -59,14 +65,14 @@ describe('communication middleware', () => {
|
|
|
59
65
|
type: 'text',
|
|
60
66
|
properties: []
|
|
61
67
|
});
|
|
62
|
-
|
|
68
|
+
mockStartPostMessageCommunication.mock.calls[0][1](action);
|
|
63
69
|
expect(dispatch).toHaveBeenCalledTimes(1);
|
|
64
70
|
expect(dispatch).toHaveBeenNthCalledWith(1, action);
|
|
65
71
|
});
|
|
66
72
|
|
|
67
73
|
test('outline changed in UI5 application', () => {
|
|
68
74
|
const action = common.outlineChanged([]);
|
|
69
|
-
|
|
75
|
+
mockStartPostMessageCommunication.mock.calls[0][1](action);
|
|
70
76
|
expect(dispatch).toHaveBeenCalledTimes(1);
|
|
71
77
|
expect(dispatch).toHaveBeenNthCalledWith(1, action);
|
|
72
78
|
});
|
|
@@ -77,13 +83,13 @@ describe('communication middleware', () => {
|
|
|
77
83
|
propertyName: 'text',
|
|
78
84
|
errorMessage: 'change failed'
|
|
79
85
|
});
|
|
80
|
-
|
|
86
|
+
mockStartPostMessageCommunication.mock.calls[0][1](action);
|
|
81
87
|
expect(dispatch).toHaveBeenCalledTimes(1);
|
|
82
88
|
expect(dispatch).toHaveBeenNthCalledWith(1, action);
|
|
83
89
|
});
|
|
84
90
|
|
|
85
91
|
test('getTarget', () => {
|
|
86
|
-
expect(
|
|
92
|
+
expect(mockStartPostMessageCommunication.mock.calls[0][0]()).toEqual('Target');
|
|
87
93
|
});
|
|
88
94
|
|
|
89
95
|
test('property change - send action', () => {
|
|
@@ -104,17 +110,12 @@ describe('communication middleware', () => {
|
|
|
104
110
|
"type": "[ext] property-changed",
|
|
105
111
|
}
|
|
106
112
|
`);
|
|
107
|
-
expect(
|
|
113
|
+
expect(mockSendAction).toHaveBeenCalledTimes(1);
|
|
108
114
|
});
|
|
109
115
|
|
|
110
116
|
test('select control - send action', () => {
|
|
111
117
|
const action = common.selectControl('01-02');
|
|
112
118
|
const next = jest.fn().mockReturnValue(action);
|
|
113
|
-
jest.mock('@sap-ux-private/control-property-editor-common', () => {
|
|
114
|
-
return {
|
|
115
|
-
selectControl: { type: '[ext] select-control' }
|
|
116
|
-
};
|
|
117
|
-
});
|
|
118
119
|
const result = middleWare(next)(action);
|
|
119
120
|
expect(result).toMatchInlineSnapshot(`
|
|
120
121
|
Object {
|
|
@@ -122,17 +123,12 @@ describe('communication middleware', () => {
|
|
|
122
123
|
"type": "[ext] select-control",
|
|
123
124
|
}
|
|
124
125
|
`);
|
|
125
|
-
expect(
|
|
126
|
+
expect(mockSendAction).toHaveBeenCalledTimes(1);
|
|
126
127
|
});
|
|
127
128
|
|
|
128
129
|
test('add extension point - send action', () => {
|
|
129
130
|
const action = common.addExtensionPoint({ controlId: 'control1' } as common.OutlineNode);
|
|
130
131
|
const next = jest.fn().mockReturnValue(action);
|
|
131
|
-
jest.mock('@sap-ux-private/control-property-editor-common', () => {
|
|
132
|
-
return {
|
|
133
|
-
addExtensionPoint: { type: '[ext] add-extension-point' }
|
|
134
|
-
};
|
|
135
|
-
});
|
|
136
132
|
const result = middleWare(next)(action);
|
|
137
133
|
expect(result).toMatchInlineSnapshot(`
|
|
138
134
|
Object {
|
|
@@ -142,17 +138,12 @@ describe('communication middleware', () => {
|
|
|
142
138
|
"type": "[ext] add-extension-point",
|
|
143
139
|
}
|
|
144
140
|
`);
|
|
145
|
-
expect(
|
|
141
|
+
expect(mockSendAction).toHaveBeenCalledTimes(1);
|
|
146
142
|
});
|
|
147
143
|
|
|
148
144
|
test('undo - send action', () => {
|
|
149
145
|
const action = common.undo();
|
|
150
146
|
const next = jest.fn().mockReturnValue(action);
|
|
151
|
-
jest.mock('@sap-ux-private/control-property-editor-common', () => {
|
|
152
|
-
return {
|
|
153
|
-
undo: { type: '[ext] undo' }
|
|
154
|
-
};
|
|
155
|
-
});
|
|
156
147
|
const result = middleWare(next)(action);
|
|
157
148
|
expect(result).toMatchInlineSnapshot(`
|
|
158
149
|
Object {
|
|
@@ -160,17 +151,12 @@ describe('communication middleware', () => {
|
|
|
160
151
|
"type": "[ext] undo",
|
|
161
152
|
}
|
|
162
153
|
`);
|
|
163
|
-
expect(
|
|
154
|
+
expect(mockSendAction).toHaveBeenCalledTimes(1);
|
|
164
155
|
});
|
|
165
156
|
|
|
166
157
|
test('redo - send action', () => {
|
|
167
158
|
const action = common.redo();
|
|
168
159
|
const next = jest.fn().mockReturnValue(action);
|
|
169
|
-
jest.mock('@sap-ux-private/control-property-editor-common', () => {
|
|
170
|
-
return {
|
|
171
|
-
redo: { type: '[ext] redo' }
|
|
172
|
-
};
|
|
173
|
-
});
|
|
174
160
|
const result = middleWare(next)(action);
|
|
175
161
|
expect(result).toMatchInlineSnapshot(`
|
|
176
162
|
Object {
|
|
@@ -178,17 +164,12 @@ describe('communication middleware', () => {
|
|
|
178
164
|
"type": "[ext] redo",
|
|
179
165
|
}
|
|
180
166
|
`);
|
|
181
|
-
expect(
|
|
167
|
+
expect(mockSendAction).toHaveBeenCalledTimes(1);
|
|
182
168
|
});
|
|
183
169
|
|
|
184
170
|
test('save - send action', () => {
|
|
185
171
|
const action = common.save();
|
|
186
172
|
const next = jest.fn().mockReturnValue(action);
|
|
187
|
-
jest.mock('@sap-ux-private/control-property-editor-common', () => {
|
|
188
|
-
return {
|
|
189
|
-
save: { type: '[ext] save' }
|
|
190
|
-
};
|
|
191
|
-
});
|
|
192
173
|
const result = middleWare(next)(action);
|
|
193
174
|
expect(result).toMatchInlineSnapshot(`
|
|
194
175
|
Object {
|
|
@@ -196,17 +177,12 @@ describe('communication middleware', () => {
|
|
|
196
177
|
"type": "[ext] save",
|
|
197
178
|
}
|
|
198
179
|
`);
|
|
199
|
-
expect(
|
|
180
|
+
expect(mockSendAction).toHaveBeenCalledTimes(1);
|
|
200
181
|
});
|
|
201
182
|
|
|
202
183
|
test('setAppMode(adaptation) mode - send action', () => {
|
|
203
184
|
const action = common.setAppMode('adaptation');
|
|
204
185
|
const next = jest.fn().mockReturnValue(action);
|
|
205
|
-
jest.mock('@sap-ux-private/control-property-editor-common', () => {
|
|
206
|
-
return {
|
|
207
|
-
setAppMode: { type: '[ext] setAppMode' }
|
|
208
|
-
};
|
|
209
|
-
});
|
|
210
186
|
const result = middleWare(next)(action);
|
|
211
187
|
expect(result).toMatchInlineSnapshot(`
|
|
212
188
|
Object {
|
|
@@ -214,16 +190,11 @@ describe('communication middleware', () => {
|
|
|
214
190
|
"type": "[ext] set-app-mode",
|
|
215
191
|
}
|
|
216
192
|
`);
|
|
217
|
-
expect(
|
|
193
|
+
expect(mockSendAction).toHaveBeenCalledTimes(1);
|
|
218
194
|
});
|
|
219
195
|
test('setAppMode(navigation) mode - send action', () => {
|
|
220
196
|
const action = common.setAppMode('navigation');
|
|
221
197
|
const next = jest.fn().mockReturnValue(action);
|
|
222
|
-
jest.mock('@sap-ux-private/control-property-editor-common', () => {
|
|
223
|
-
return {
|
|
224
|
-
setAppMode: { type: '[ext] setAppMode' }
|
|
225
|
-
};
|
|
226
|
-
});
|
|
227
198
|
const result = middleWare(next)(action);
|
|
228
199
|
expect(result).toMatchInlineSnapshot(`
|
|
229
200
|
Object {
|
|
@@ -231,16 +202,11 @@ describe('communication middleware', () => {
|
|
|
231
202
|
"type": "[ext] set-app-mode",
|
|
232
203
|
}
|
|
233
204
|
`);
|
|
234
|
-
expect(
|
|
205
|
+
expect(mockSendAction).toHaveBeenCalledTimes(1);
|
|
235
206
|
});
|
|
236
207
|
test('externalFileChange - send action', () => {
|
|
237
208
|
const action = common.externalFileChange('file-path');
|
|
238
209
|
const next = jest.fn().mockReturnValue(action);
|
|
239
|
-
jest.mock('@sap-ux-private/control-property-editor-common', () => {
|
|
240
|
-
return {
|
|
241
|
-
externalFileChange: { type: '[ext] external-file-change' }
|
|
242
|
-
};
|
|
243
|
-
});
|
|
244
210
|
const result = middleWare(next)(action);
|
|
245
211
|
expect(result).toMatchInlineSnapshot(`
|
|
246
212
|
Object {
|
|
@@ -248,6 +214,6 @@ describe('communication middleware', () => {
|
|
|
248
214
|
"type": "[ext] external-file-change",
|
|
249
215
|
}
|
|
250
216
|
`);
|
|
251
|
-
expect(
|
|
217
|
+
expect(mockSendAction).toHaveBeenCalledTimes(1);
|
|
252
218
|
});
|
|
253
219
|
});
|
|
@@ -1,20 +1,12 @@
|
|
|
1
1
|
import type { PendingChange, SavedChange } from '@sap-ux-private/control-property-editor-common';
|
|
2
|
+
import { selectControl } from '@sap-ux-private/control-property-editor-common';
|
|
2
3
|
import type { FilterOptions, ChangesSlice } from '../../../../src/slice';
|
|
3
4
|
import React from 'react';
|
|
4
5
|
import { screen, fireEvent } from '@testing-library/react';
|
|
5
|
-
import * as cpeCommon from '@sap-ux-private/control-property-editor-common';
|
|
6
|
-
import * as reactRedux from 'react-redux';
|
|
7
6
|
import { render } from '../../utils';
|
|
8
7
|
import { FilterName } from '../../../../src/slice';
|
|
9
8
|
import { ChangesPanel } from '../../../../src/panels/changes';
|
|
10
9
|
|
|
11
|
-
jest.mock('@sap-ux-private/control-property-editor-common', () => {
|
|
12
|
-
return {
|
|
13
|
-
__esModule: true,
|
|
14
|
-
...jest.requireActual('@sap-ux-private/control-property-editor-common')
|
|
15
|
-
};
|
|
16
|
-
});
|
|
17
|
-
|
|
18
10
|
const getChanges = (generateSavedChanges = false, filterByKind = ''): ChangesSlice => {
|
|
19
11
|
const pending: PendingChange[] = !generateSavedChanges
|
|
20
12
|
? [
|
|
@@ -763,10 +755,7 @@ describe('ChangePanel', () => {
|
|
|
763
755
|
});
|
|
764
756
|
|
|
765
757
|
test('saved control change - link', () => {
|
|
766
|
-
|
|
767
|
-
jest.spyOn(reactRedux, 'useDispatch').mockReturnValue(jest.fn());
|
|
768
|
-
|
|
769
|
-
render(<ChangesPanel />, {
|
|
758
|
+
const { dispatch } = render(<ChangesPanel />, {
|
|
770
759
|
initialState: {
|
|
771
760
|
changes: {
|
|
772
761
|
controls: {},
|
|
@@ -804,8 +793,7 @@ describe('ChangePanel', () => {
|
|
|
804
793
|
expect(link).toBeInTheDocument();
|
|
805
794
|
|
|
806
795
|
link.click();
|
|
807
|
-
expect(
|
|
808
|
-
expect(cpeCommon.selectControl).toHaveBeenCalledWith('testId1');
|
|
796
|
+
expect(dispatch).toHaveBeenCalledWith(selectControl('testId1'));
|
|
809
797
|
});
|
|
810
798
|
|
|
811
799
|
test('Filter unsaved changes', () => {
|
|
@@ -2,20 +2,13 @@ import { FileChange } from '../../../../src/panels/changes/FileChange';
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { screen } from '@testing-library/react';
|
|
4
4
|
import { render } from '../../utils';
|
|
5
|
-
import { useDispatch } from 'react-redux';
|
|
6
5
|
import { reloadApplication } from '@sap-ux-private/control-property-editor-common';
|
|
7
6
|
|
|
8
|
-
// Mock the useDispatch hook
|
|
9
|
-
jest.mock('react-redux', () => ({
|
|
10
|
-
...jest.requireActual('react-redux'),
|
|
11
|
-
useDispatch: jest.fn().mockReturnValue(jest.fn())
|
|
12
|
-
}));
|
|
13
|
-
|
|
14
7
|
describe('FileChange', () => {
|
|
15
8
|
it('renders the component with correct text when fileName is provided', () => {
|
|
16
9
|
const hasUnsavedChanges = true;
|
|
17
10
|
|
|
18
|
-
render(<FileChange hasUnsavedChanges={hasUnsavedChanges} />);
|
|
11
|
+
const { dispatch } = render(<FileChange hasUnsavedChanges={hasUnsavedChanges} />);
|
|
19
12
|
|
|
20
13
|
const saveAndReloadLink = screen.getByText(/Save and Reload/i);
|
|
21
14
|
expect(saveAndReloadLink).toBeInTheDocument();
|
|
@@ -24,8 +17,7 @@ describe('FileChange', () => {
|
|
|
24
17
|
expect(detailLinkText).toBeInTheDocument();
|
|
25
18
|
|
|
26
19
|
saveAndReloadLink.click();
|
|
27
|
-
|
|
28
|
-
expect(hookMock as jest.Mock).toHaveBeenCalledWith({
|
|
20
|
+
expect(dispatch).toHaveBeenCalledWith({
|
|
29
21
|
payload: {
|
|
30
22
|
save: true
|
|
31
23
|
},
|
|
@@ -3,7 +3,6 @@ import React from 'react';
|
|
|
3
3
|
import type { StringControlPropertyWithOptions } from '@sap-ux-private/control-property-editor-common';
|
|
4
4
|
import { DROPDOWN_EDITOR_TYPE, PropertyType, STRING_VALUE_TYPE } from '@sap-ux-private/control-property-editor-common';
|
|
5
5
|
import { DropdownEditor, valueChanged } from '../../../../src/panels/properties/DropdownEditor';
|
|
6
|
-
import * as slice from '../../../../src/slice';
|
|
7
6
|
import '@testing-library/jest-dom';
|
|
8
7
|
|
|
9
8
|
import { render } from '../../utils';
|
|
@@ -28,7 +27,6 @@ describe('DropdownEditor', () => {
|
|
|
28
27
|
propertyType: PropertyType.ControlProperty
|
|
29
28
|
};
|
|
30
29
|
const testId = `${propertyName}--DropdownEditor`;
|
|
31
|
-
jest.spyOn(slice, 'changeProperty');
|
|
32
30
|
|
|
33
31
|
cleanup();
|
|
34
32
|
|
|
@@ -18,7 +18,6 @@ import { getValueForInputType, InputTypeToggle } from '../../../../src/panels/pr
|
|
|
18
18
|
import type { InputTypeToggleOptionProps } from '../../../../src/panels/properties/types';
|
|
19
19
|
import { InputType } from '../../../../src/panels/properties/types';
|
|
20
20
|
import { render } from '../../utils';
|
|
21
|
-
import * as slice from '../../../../src/slice';
|
|
22
21
|
|
|
23
22
|
describe('InputTypeToggle', () => {
|
|
24
23
|
const controlId = 'testControlId';
|
|
@@ -101,10 +100,8 @@ describe('InputTypeToggle', () => {
|
|
|
101
100
|
};
|
|
102
101
|
const testId = `${propertyName}--InputTypeToggle--${InputType.booleanTrue}`;
|
|
103
102
|
|
|
104
|
-
const spyGetChangePropertyAction = jest.spyOn(slice, 'changeProperty');
|
|
105
|
-
|
|
106
103
|
// act
|
|
107
|
-
render(
|
|
104
|
+
const { dispatch } = render(
|
|
108
105
|
<InputTypeToggle
|
|
109
106
|
inputTypeProps={inputTypeProps}
|
|
110
107
|
property={property}
|
|
@@ -118,12 +115,14 @@ describe('InputTypeToggle', () => {
|
|
|
118
115
|
cleanup();
|
|
119
116
|
|
|
120
117
|
// assert
|
|
121
|
-
expect(
|
|
122
|
-
expect(spyGetChangePropertyAction).toHaveBeenCalledWith(
|
|
118
|
+
expect(dispatch).toHaveBeenCalledWith(
|
|
123
119
|
expect.objectContaining({
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
120
|
+
type: 'app/change-property',
|
|
121
|
+
payload: expect.objectContaining({
|
|
122
|
+
controlId,
|
|
123
|
+
propertyName,
|
|
124
|
+
value: true
|
|
125
|
+
})
|
|
127
126
|
})
|
|
128
127
|
);
|
|
129
128
|
});
|
package/test/unit/setup.ts
CHANGED
|
@@ -1,11 +1,27 @@
|
|
|
1
1
|
import { initIcons } from '@sap-ux/ui-components';
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import i18n from 'i18next';
|
|
4
|
+
import { initReactI18next } from 'react-i18next';
|
|
5
|
+
import i18nEn from '../../src/i18n/i18n.json';
|
|
4
6
|
import { registerAppIcons } from '../../src/icons';
|
|
5
7
|
import { mockResizeObserver } from '../utils/utils';
|
|
6
8
|
|
|
7
9
|
mockResizeObserver();
|
|
8
|
-
|
|
10
|
+
// Initialize i18n synchronously for tests (initImmediate: false prevents async init)
|
|
11
|
+
i18n.use(initReactI18next).init({
|
|
12
|
+
resources: {
|
|
13
|
+
en: {
|
|
14
|
+
translation: i18nEn
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
lng: 'en',
|
|
18
|
+
fallbackLng: 'en',
|
|
19
|
+
interpolation: {
|
|
20
|
+
escapeValue: false
|
|
21
|
+
},
|
|
22
|
+
showSupportNotice: false,
|
|
23
|
+
initImmediate: false
|
|
24
|
+
});
|
|
9
25
|
registerAppIcons();
|
|
10
26
|
initIcons();
|
|
11
27
|
|
package/test/utils/utils.tsx
CHANGED
package/tsconfig.eslint.json
CHANGED
package/tsconfig.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
],
|
|
10
10
|
"strictNullChecks": true,
|
|
11
11
|
"outDir": "dist",
|
|
12
|
-
"module": "
|
|
12
|
+
"module": "NodeNext",
|
|
13
13
|
"rootDir": ".",
|
|
14
14
|
"baseUrl": ".",
|
|
15
15
|
"types": [
|
|
@@ -20,14 +20,13 @@
|
|
|
20
20
|
"include": [
|
|
21
21
|
"src/**/*.json",
|
|
22
22
|
"src/**/*.ts",
|
|
23
|
-
"src/**/*.tsx"
|
|
24
|
-
"test/**/*.ts",
|
|
25
|
-
"test/**/*.tsx"
|
|
23
|
+
"src/**/*.tsx"
|
|
26
24
|
],
|
|
27
25
|
"exclude": [
|
|
28
26
|
"dist",
|
|
29
27
|
"node_modules",
|
|
30
|
-
"coverage"
|
|
28
|
+
"coverage",
|
|
29
|
+
"test"
|
|
31
30
|
],
|
|
32
31
|
"references": [
|
|
33
32
|
{
|
package/jest.config.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
const config = require('../../jest.base');
|
|
2
|
-
config.testEnvironment = 'jsdom';
|
|
3
|
-
config.collectCoverageFrom = ['src/**/*.{ts,tsx}'];
|
|
4
|
-
config.transform = {
|
|
5
|
-
'^.+\\.test.tsx?$': 'ts-jest',
|
|
6
|
-
'.+\\.(css|sass|scss)$': 'jest-scss-transform'
|
|
7
|
-
};
|
|
8
|
-
config.globals = {
|
|
9
|
-
'ts-jest': {
|
|
10
|
-
jsx: 'react',
|
|
11
|
-
diagnostics: {
|
|
12
|
-
warnOnly: true,
|
|
13
|
-
exclude: /\.(spec|test)\.ts$/
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
config.preset = 'ts-jest';
|
|
18
|
-
config.transformIgnorePatterns = ['<rootDir>/node_modules/'];
|
|
19
|
-
config.testMatch = ['**/test/unit/**/*.(test).ts(x)?'];
|
|
20
|
-
config.setupFiles = ['./test/unit/setup.ts'];
|
|
21
|
-
module.exports = config;
|