@reltio/components 1.4.1906 → 1.4.1907
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/cjs/ActionsPanel/ActionsPanel.test.js +133 -49
- package/cjs/AttributeListItem/AttributeListItem.spec.js +147 -118
- package/cjs/AttributeSelector/AttributeSelector.specs.js +125 -193
- package/cjs/AttributesErrorsPanel/AttributesErrorsPanel.specs.js +128 -71
- package/cjs/AttributesErrorsPanel/components/Error/Error.specs.js +96 -90
- package/cjs/AttributesErrorsPanel/store.test-data.d.ts +22 -0
- package/cjs/AttributesErrorsPanel/store.test-data.js +29 -0
- package/cjs/AttributesFilterSelector/AttributesFilterSelector.test.js +127 -105
- package/cjs/AttributesFiltersButton/AttributesFiltersButton.test.js +218 -136
- package/cjs/AttributesValuesEditor/AttributesValuesEditor.test.js +92 -88
- package/cjs/AttributesView/AttributesView.test.js +67 -34
- package/cjs/AutoSizeList/AutoSizeList.test.js +81 -59
- package/cjs/{ActionsPanel/components/MenuItemRenderer/MenuItemRenderer.spec.js → AvatarWithFallback/AvatarWithFallback.test.js} +15 -31
- package/cjs/BarChart/BarChart.test.js +128 -65
- package/cjs/BasicAttributeSelector/BasicAttributeSelector.spec.js +27 -10
- package/cjs/BasicViewContent/BasicViewContent.test.js +7 -9
- package/cjs/BlobRenderer/BlobRenderer.test.js +28 -9
- package/cjs/BooleanRadioEditor/BooleanRadioEditor.test.js +89 -35
- package/cjs/BubbleChart/BubbleChart.test.js +111 -87
- package/cjs/CloudChart/CloudChart.test.js +95 -36
- package/cjs/CollaborationItem/CollaborationItem.test.js +67 -30
- package/cjs/CollaborationItem/components/Comment/Comment.test.js +221 -189
- package/cjs/CollaborationItem/components/CommentContent/CommentContent.test.js +46 -81
- package/cjs/CollaborationItem/components/RepliedComment/RepliedComment.test.js +194 -163
- package/cjs/CollaborationItem/components/SendMessageArea/SendMessageArea.test.js +307 -266
- package/cjs/CollapseButton/CollapseButton.test.js +74 -15
- package/cjs/CollapseRowButton/CollapseRowButton.test.js +82 -24
- package/cjs/ColorBar/ColorBar.test.js +13 -15
- package/cjs/ColumnsSettings/components/ColumnsSettingsPopup/ColumnsSettingsPopup.spec.js +207 -129
- package/cjs/CommentsContainer/CommentsContainer.test.js +282 -211
- package/cjs/CommentsContainer/components/CollaborationPopup/CollaborationPopup.test.js +183 -122
- package/cjs/ConfigureColumnsPopup/ConfigureColumnsPopup.test.js +42 -41
- package/cjs/ConfirmDeleteDialog/ConfirmDeleteDialog.test.js +77 -28
- package/cjs/ConfirmationDialog/ConfirmationDialog.test.js +85 -48
- package/cjs/ConnectionEditor/ConnectionEditor.test.js +299 -282
- package/esm/ActionsPanel/ActionsPanel.test.js +133 -49
- package/esm/AttributeListItem/AttributeListItem.spec.js +149 -97
- package/esm/AttributeSelector/AttributeSelector.specs.js +125 -193
- package/esm/AttributesErrorsPanel/AttributesErrorsPanel.specs.js +128 -71
- package/esm/AttributesErrorsPanel/components/Error/Error.specs.js +98 -72
- package/esm/AttributesErrorsPanel/store.test-data.d.ts +22 -0
- package/esm/AttributesErrorsPanel/store.test-data.js +26 -0
- package/esm/AttributesFilterSelector/AttributesFilterSelector.test.js +129 -84
- package/esm/AttributesFiltersButton/AttributesFiltersButton.test.js +218 -136
- package/esm/AttributesValuesEditor/AttributesValuesEditor.test.js +94 -67
- package/esm/AttributesView/AttributesView.test.js +67 -34
- package/esm/AutoSizeList/AutoSizeList.test.js +81 -59
- package/esm/{ActionsPanel/components/MenuItemRenderer/MenuItemRenderer.spec.js → AvatarWithFallback/AvatarWithFallback.test.js} +16 -32
- package/esm/BarChart/BarChart.test.js +128 -65
- package/esm/BasicAttributeSelector/BasicAttributeSelector.spec.js +27 -10
- package/esm/BasicViewContent/BasicViewContent.test.js +7 -9
- package/esm/BlobRenderer/BlobRenderer.test.js +28 -9
- package/esm/BooleanRadioEditor/BooleanRadioEditor.test.js +89 -35
- package/esm/BubbleChart/BubbleChart.test.js +111 -87
- package/esm/CloudChart/CloudChart.test.js +95 -36
- package/esm/CollaborationItem/CollaborationItem.test.js +67 -30
- package/esm/CollaborationItem/components/Comment/Comment.test.js +221 -189
- package/esm/CollaborationItem/components/CommentContent/CommentContent.test.js +46 -58
- package/esm/CollaborationItem/components/RepliedComment/RepliedComment.test.js +194 -163
- package/esm/CollaborationItem/components/SendMessageArea/SendMessageArea.test.js +307 -266
- package/esm/CollapseButton/CollapseButton.test.js +74 -15
- package/esm/CollapseRowButton/CollapseRowButton.test.js +82 -24
- package/esm/ColorBar/ColorBar.test.js +13 -15
- package/esm/ColumnsSettings/components/ColumnsSettingsPopup/ColumnsSettingsPopup.spec.js +207 -129
- package/esm/CommentsContainer/CommentsContainer.test.js +282 -211
- package/esm/CommentsContainer/components/CollaborationPopup/CollaborationPopup.test.js +182 -101
- package/esm/ConfigureColumnsPopup/ConfigureColumnsPopup.test.js +42 -41
- package/esm/ConfirmDeleteDialog/ConfirmDeleteDialog.test.js +77 -28
- package/esm/ConfirmationDialog/ConfirmationDialog.test.js +85 -48
- package/esm/ConnectionEditor/ConnectionEditor.test.js +300 -283
- package/package.json +1 -1
- package/cjs/AttributesErrorsPanel/components/ErrorsPanel/ErrorsPanel.specs.js +0 -100
- package/cjs/AttributesFiltersButton/components/ActionButtons/ActionButtons.test.d.ts +0 -1
- package/cjs/AttributesFiltersButton/components/ActionButtons/ActionButtons.test.js +0 -46
- package/cjs/AvatarWithFallback/AvatarWithFallback.specs.d.ts +0 -1
- package/cjs/AvatarWithFallback/AvatarWithFallback.specs.js +0 -27
- package/cjs/BooleanRadioEditor/components/BooleanEditor/BooleanEditor.test.d.ts +0 -1
- package/cjs/BooleanRadioEditor/components/BooleanEditor/BooleanEditor.test.js +0 -27
- package/cjs/CollaborationItem/components/Avatar/Avatar.test.d.ts +0 -1
- package/cjs/CollaborationItem/components/Avatar/Avatar.test.js +0 -15
- package/cjs/CollaborationItem/components/TextFieldWithMentions/TextFieldWithMentions.test.d.ts +0 -1
- package/cjs/CollaborationItem/components/TextFieldWithMentions/TextFieldWithMentions.test.js +0 -80
- package/esm/ActionsPanel/components/MenuItemRenderer/MenuItemRenderer.spec.d.ts +0 -1
- package/esm/AttributesErrorsPanel/components/ErrorsPanel/ErrorsPanel.specs.d.ts +0 -1
- package/esm/AttributesErrorsPanel/components/ErrorsPanel/ErrorsPanel.specs.js +0 -95
- package/esm/AttributesFiltersButton/components/ActionButtons/ActionButtons.test.d.ts +0 -1
- package/esm/AttributesFiltersButton/components/ActionButtons/ActionButtons.test.js +0 -41
- package/esm/AvatarWithFallback/AvatarWithFallback.specs.d.ts +0 -1
- package/esm/AvatarWithFallback/AvatarWithFallback.specs.js +0 -22
- package/esm/BooleanRadioEditor/components/BooleanEditor/BooleanEditor.test.d.ts +0 -1
- package/esm/BooleanRadioEditor/components/BooleanEditor/BooleanEditor.test.js +0 -22
- package/esm/CollaborationItem/components/Avatar/Avatar.test.d.ts +0 -1
- package/esm/CollaborationItem/components/Avatar/Avatar.test.js +0 -10
- package/esm/CollaborationItem/components/TextFieldWithMentions/TextFieldWithMentions.test.d.ts +0 -1
- package/esm/CollaborationItem/components/TextFieldWithMentions/TextFieldWithMentions.test.js +0 -55
- /package/cjs/{ActionsPanel/components/MenuItemRenderer/MenuItemRenderer.spec.d.ts → AvatarWithFallback/AvatarWithFallback.test.d.ts} +0 -0
- /package/{cjs/AttributesErrorsPanel/components/ErrorsPanel/ErrorsPanel.specs.d.ts → esm/AvatarWithFallback/AvatarWithFallback.test.d.ts} +0 -0
|
@@ -9,72 +9,156 @@ var __assign = (this && this.__assign) || function () {
|
|
|
9
9
|
};
|
|
10
10
|
return __assign.apply(this, arguments);
|
|
11
11
|
};
|
|
12
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
13
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
14
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
15
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
16
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
17
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
18
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
22
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
23
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
24
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
25
|
+
function step(op) {
|
|
26
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
27
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
28
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
29
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
30
|
+
switch (op[0]) {
|
|
31
|
+
case 0: case 1: t = op; break;
|
|
32
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
33
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
34
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
35
|
+
default:
|
|
36
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
37
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
38
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
39
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
40
|
+
if (t[2]) _.ops.pop();
|
|
41
|
+
_.trys.pop(); continue;
|
|
42
|
+
}
|
|
43
|
+
op = body.call(thisArg, _);
|
|
44
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
45
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
|
+
}
|
|
47
|
+
};
|
|
12
48
|
import React from 'react';
|
|
13
|
-
import { omit } from 'ramda';
|
|
14
|
-
import { shallow } from 'enzyme';
|
|
15
49
|
import { ActionsPanel } from './ActionsPanel';
|
|
16
|
-
import {
|
|
50
|
+
import { render, screen, within } from '@testing-library/react';
|
|
51
|
+
import userEvent from '@testing-library/user-event';
|
|
17
52
|
describe('ActionsPanel tests', function () {
|
|
18
|
-
var MergeButton = function () {
|
|
53
|
+
var MergeButton = function (_a) {
|
|
54
|
+
var mode = _a.mode, onMenuClose = _a.onMenuClose;
|
|
55
|
+
return (React.createElement("button", { "data-reltio-id": "testButton", "data-mode": mode, onClick: onMenuClose }));
|
|
56
|
+
};
|
|
19
57
|
var actions = [
|
|
20
|
-
{ ActionButton: MergeButton,
|
|
21
|
-
{ ActionButton: MergeButton
|
|
22
|
-
{ ActionButton: MergeButton
|
|
23
|
-
{ ActionButton: MergeButton,
|
|
58
|
+
{ ActionButton: MergeButton, show: true },
|
|
59
|
+
{ ActionButton: MergeButton },
|
|
60
|
+
{ ActionButton: MergeButton },
|
|
61
|
+
{ ActionButton: MergeButton, show: false }
|
|
24
62
|
];
|
|
63
|
+
var setUp = function (props) {
|
|
64
|
+
if (props === void 0) { props = { actions: actions }; }
|
|
65
|
+
var user = userEvent.setup();
|
|
66
|
+
return __assign({ user: user }, render(React.createElement(ActionsPanel, __assign({}, props))));
|
|
67
|
+
};
|
|
25
68
|
it('should render main parts', function () {
|
|
26
|
-
|
|
27
|
-
expect(
|
|
28
|
-
expect(
|
|
69
|
+
setUp();
|
|
70
|
+
expect(screen.getAllByTestId('testButton')).toHaveLength(2);
|
|
71
|
+
expect(screen.getByLabelText('More actions')).toBeInTheDocument();
|
|
29
72
|
});
|
|
30
73
|
it('should render empty panel if actions is empty array', function () {
|
|
31
|
-
|
|
32
|
-
expect(
|
|
33
|
-
expect(
|
|
74
|
+
setUp({ actions: [] });
|
|
75
|
+
expect(screen.queryByTestId('testButton')).not.toBeInTheDocument();
|
|
76
|
+
expect(screen.queryByLabelText('More actions')).not.toBeInTheDocument();
|
|
34
77
|
});
|
|
35
78
|
it('should not render DropDownMenuButton if length of actions <= numberOfButtons', function () {
|
|
36
|
-
|
|
37
|
-
expect(
|
|
38
|
-
expect(
|
|
79
|
+
setUp({ actions: actions, numberOfButtons: actions.length });
|
|
80
|
+
expect(screen.getAllByTestId('testButton')).toHaveLength(3);
|
|
81
|
+
expect(screen.queryByLabelText('More actions')).not.toBeInTheDocument();
|
|
39
82
|
});
|
|
40
83
|
it('should render numberOfButtons action button from actions', function () {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
expect(
|
|
44
|
-
expect(component.find(DropDownMenuButton)).toHaveLength(1);
|
|
84
|
+
setUp({ actions: actions, numberOfButtons: 1 });
|
|
85
|
+
expect(screen.queryByTestId('testButton')).toBeInTheDocument();
|
|
86
|
+
expect(screen.queryByLabelText('More actions')).toBeInTheDocument();
|
|
45
87
|
});
|
|
46
|
-
it('should
|
|
47
|
-
var
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
88
|
+
it('should call onActionsMenuOpen, onActionsMenuClose ', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
89
|
+
var onActionsMenuOpenSpy, onActionsMenuCloseSpy, user;
|
|
90
|
+
return __generator(this, function (_a) {
|
|
91
|
+
switch (_a.label) {
|
|
92
|
+
case 0:
|
|
93
|
+
onActionsMenuOpenSpy = jest.fn();
|
|
94
|
+
onActionsMenuCloseSpy = jest.fn();
|
|
95
|
+
user = setUp({
|
|
96
|
+
actions: actions,
|
|
97
|
+
onActionsMenuClose: onActionsMenuCloseSpy,
|
|
98
|
+
onActionsMenuOpen: onActionsMenuOpenSpy
|
|
99
|
+
}).user;
|
|
100
|
+
return [4 /*yield*/, user.click(screen.getByLabelText('More actions'))];
|
|
101
|
+
case 1:
|
|
102
|
+
_a.sent();
|
|
103
|
+
expect(onActionsMenuOpenSpy).toHaveBeenCalled();
|
|
104
|
+
return [4 /*yield*/, user.click(screen.getByLabelText('More actions'))];
|
|
105
|
+
case 2:
|
|
106
|
+
_a.sent();
|
|
107
|
+
expect(onActionsMenuCloseSpy).toHaveBeenCalled();
|
|
108
|
+
return [2 /*return*/];
|
|
109
|
+
}
|
|
54
110
|
});
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
111
|
+
}); });
|
|
112
|
+
it('should render buttons for default mode', function () {
|
|
113
|
+
setUp();
|
|
114
|
+
var buttons = screen.getAllByTestId('testButton');
|
|
115
|
+
expect(buttons).toHaveLength(2);
|
|
116
|
+
buttons.forEach(function (button) {
|
|
117
|
+
expect(button).toHaveAttribute('data-mode', 'button');
|
|
61
118
|
});
|
|
62
119
|
});
|
|
63
|
-
it('should render
|
|
64
|
-
|
|
65
|
-
var
|
|
66
|
-
var component = shallow(React.createElement(ActionsPanel, { actions: actions, mode: "hover", onActionsMenuOpen: onActionsMenuOpen, onActionsMenuClose: onActionsMenuClose }));
|
|
67
|
-
var buttons = component.find(MergeButton);
|
|
120
|
+
it('should render buttons for hover mode', function () {
|
|
121
|
+
setUp({ actions: actions, mode: 'hover' });
|
|
122
|
+
var buttons = screen.getAllByTestId('testButton');
|
|
68
123
|
expect(buttons).toHaveLength(2);
|
|
69
|
-
buttons.
|
|
70
|
-
expect(button
|
|
71
|
-
});
|
|
72
|
-
var dropDownMenuButton = component.find(DropDownMenuButton);
|
|
73
|
-
expect(dropDownMenuButton).toHaveLength(1);
|
|
74
|
-
expect(dropDownMenuButton.props()).toMatchObject({
|
|
75
|
-
menuItems: [actions[2]],
|
|
76
|
-
onMenuOpen: onActionsMenuOpen,
|
|
77
|
-
onMenuClose: onActionsMenuClose
|
|
124
|
+
buttons.forEach(function (button) {
|
|
125
|
+
expect(button).toHaveAttribute('data-mode', 'iconButton');
|
|
78
126
|
});
|
|
79
127
|
});
|
|
128
|
+
describe('menu item tests', function () {
|
|
129
|
+
it('should call onActionsMenuClose from menu item', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
130
|
+
var onActionsMenuCloseSpy, user, menu;
|
|
131
|
+
return __generator(this, function (_a) {
|
|
132
|
+
switch (_a.label) {
|
|
133
|
+
case 0:
|
|
134
|
+
onActionsMenuCloseSpy = jest.fn();
|
|
135
|
+
user = setUp({ actions: actions, onActionsMenuClose: onActionsMenuCloseSpy }).user;
|
|
136
|
+
return [4 /*yield*/, user.click(screen.getByLabelText('More actions'))];
|
|
137
|
+
case 1:
|
|
138
|
+
_a.sent();
|
|
139
|
+
menu = screen.getByRole('menu');
|
|
140
|
+
return [4 /*yield*/, user.click(within(menu).getByRole('button'))];
|
|
141
|
+
case 2:
|
|
142
|
+
_a.sent();
|
|
143
|
+
expect(onActionsMenuCloseSpy).toHaveBeenCalled();
|
|
144
|
+
return [2 /*return*/];
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
}); });
|
|
148
|
+
it('should render menu button with correct mode', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
149
|
+
var user, menuButton;
|
|
150
|
+
return __generator(this, function (_a) {
|
|
151
|
+
switch (_a.label) {
|
|
152
|
+
case 0:
|
|
153
|
+
user = setUp().user;
|
|
154
|
+
return [4 /*yield*/, user.click(screen.getByLabelText('More actions'))];
|
|
155
|
+
case 1:
|
|
156
|
+
_a.sent();
|
|
157
|
+
menuButton = within(screen.getByRole('menu')).getByRole('button');
|
|
158
|
+
expect(menuButton).toHaveAttribute('data-mode', 'menuItem');
|
|
159
|
+
return [2 /*return*/];
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
}); });
|
|
163
|
+
});
|
|
80
164
|
});
|
|
@@ -9,141 +9,193 @@ var __assign = (this && this.__assign) || function () {
|
|
|
9
9
|
};
|
|
10
10
|
return __assign.apply(this, arguments);
|
|
11
11
|
};
|
|
12
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
13
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
14
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
15
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
16
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
17
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
18
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
22
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
23
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
24
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
25
|
+
function step(op) {
|
|
26
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
27
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
28
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
29
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
30
|
+
switch (op[0]) {
|
|
31
|
+
case 0: case 1: t = op; break;
|
|
32
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
33
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
34
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
35
|
+
default:
|
|
36
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
37
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
38
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
39
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
40
|
+
if (t[2]) _.ops.pop();
|
|
41
|
+
_.trys.pop(); continue;
|
|
42
|
+
}
|
|
43
|
+
op = body.call(thisArg, _);
|
|
44
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
45
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
|
+
}
|
|
47
|
+
};
|
|
12
48
|
import React from 'react';
|
|
13
49
|
import { render, screen } from '@testing-library/react';
|
|
14
|
-
import
|
|
15
|
-
import MenuItem from '@mui/material/MenuItem';
|
|
16
|
-
import ListItemText from '@mui/material/ListItemText';
|
|
17
|
-
import AttributeListItem, { RecommendedIconWithTooltip } from './AttributeListItem';
|
|
18
|
-
import Checkbox from '@mui/material/Checkbox';
|
|
19
|
-
import SimpleAttrIcon from '../icons/SimpleAttribute';
|
|
20
|
-
import NestedAttrIcon from '../icons/NestedAttribute';
|
|
21
|
-
import ReferenceAttrIcon from '../icons//ReferenceAttribute';
|
|
50
|
+
import AttributeListItem from './AttributeListItem';
|
|
22
51
|
import SomeLogoIcon from '@mui/icons-material/PlayArrow';
|
|
23
|
-
import {
|
|
52
|
+
import { getMuiIconByName } from '../test-utils';
|
|
53
|
+
import userEvent from '@testing-library/user-event';
|
|
24
54
|
describe('AttributeListItem tests', function () {
|
|
25
55
|
var defaultProps = {
|
|
26
56
|
data: {},
|
|
27
57
|
checked: false,
|
|
28
58
|
label: 'Some Title'
|
|
29
59
|
};
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
60
|
+
var setUp = function (props) {
|
|
61
|
+
if (props === void 0) { props = defaultProps; }
|
|
62
|
+
var user = userEvent.setup();
|
|
63
|
+
return __assign({ user: user }, render(React.createElement(AttributeListItem, __assign({}, props))));
|
|
64
|
+
};
|
|
65
|
+
it('should render default components', function () {
|
|
66
|
+
setUp();
|
|
67
|
+
expect(screen.getByText(defaultProps.label)).toBeInTheDocument();
|
|
68
|
+
expect(screen.getByRole('checkbox')).not.toBeDisabled();
|
|
69
|
+
expect(screen.getByTestId('SvgSimpleAttribute')).toBeInTheDocument();
|
|
35
70
|
});
|
|
36
71
|
it('should render main components with label as a node', function () {
|
|
37
|
-
var
|
|
38
|
-
|
|
39
|
-
expect(
|
|
72
|
+
var label = React.createElement("span", null, "Some Title");
|
|
73
|
+
setUp(__assign(__assign({}, defaultProps), { label: label }));
|
|
74
|
+
expect(screen.getByText('Some Title')).toBeInTheDocument();
|
|
40
75
|
});
|
|
41
76
|
it('should render checked checkbox', function () {
|
|
42
|
-
|
|
43
|
-
var
|
|
44
|
-
expect(
|
|
45
|
-
expect(
|
|
46
|
-
expect(
|
|
77
|
+
setUp(__assign(__assign({}, defaultProps), { checked: true }));
|
|
78
|
+
var chechbox = screen.getByRole('checkbox');
|
|
79
|
+
expect(chechbox).toBeChecked();
|
|
80
|
+
expect(chechbox).not.toBeDisabled();
|
|
81
|
+
expect(chechbox.parentNode).toHaveClass('checked');
|
|
47
82
|
});
|
|
48
83
|
it('should render unchecked checkbox', function () {
|
|
49
|
-
|
|
50
|
-
var
|
|
51
|
-
expect(
|
|
52
|
-
expect(
|
|
53
|
-
|
|
54
|
-
it('should render simple attribute icon by default', function () {
|
|
55
|
-
var component = mount(React.createElement(AttributeListItem, __assign({}, defaultProps)));
|
|
56
|
-
expect(component.find(SimpleAttrIcon)).toHaveLength(1);
|
|
57
|
-
expect(component.find(NestedAttrIcon)).toHaveLength(0);
|
|
58
|
-
expect(component.find(ReferenceAttrIcon)).toHaveLength(0);
|
|
59
|
-
expect(component.find(RecommendedIconWithTooltip)).toHaveLength(0);
|
|
84
|
+
setUp(__assign(__assign({}, defaultProps), { checked: false }));
|
|
85
|
+
var chechbox = screen.getByRole('checkbox');
|
|
86
|
+
expect(chechbox).not.toBeChecked();
|
|
87
|
+
expect(chechbox).not.toBeDisabled();
|
|
88
|
+
expect(chechbox.parentNode).not.toHaveClass('checked');
|
|
60
89
|
});
|
|
61
90
|
it('should render nested attribute icon', function () {
|
|
62
|
-
|
|
91
|
+
setUp(__assign(__assign({}, defaultProps), { data: {
|
|
63
92
|
attrType: {
|
|
64
93
|
type: 'Nested',
|
|
65
94
|
name: 'name',
|
|
66
95
|
uri: 'uri'
|
|
67
96
|
}
|
|
68
|
-
} }))
|
|
69
|
-
expect(
|
|
70
|
-
expect(component.find(NestedAttrIcon)).toHaveLength(1);
|
|
71
|
-
expect(component.find(ReferenceAttrIcon)).toHaveLength(0);
|
|
72
|
-
expect(component.find(RecommendedIconWithTooltip)).toHaveLength(0);
|
|
97
|
+
} }));
|
|
98
|
+
expect(screen.getByTestId('SvgNestedAttribute')).toBeInTheDocument();
|
|
73
99
|
});
|
|
74
100
|
it('should render reference attribute icon', function () {
|
|
75
|
-
|
|
101
|
+
setUp(__assign(__assign({}, defaultProps), { data: {
|
|
76
102
|
attrType: {
|
|
77
103
|
type: 'Reference',
|
|
78
104
|
name: 'name',
|
|
79
105
|
uri: 'uri'
|
|
80
106
|
}
|
|
81
|
-
} }))
|
|
82
|
-
expect(
|
|
83
|
-
expect(component.find(NestedAttrIcon)).toHaveLength(0);
|
|
84
|
-
expect(component.find(ReferenceAttrIcon)).toHaveLength(1);
|
|
85
|
-
expect(component.find(RecommendedIconWithTooltip)).toHaveLength(0);
|
|
107
|
+
} }));
|
|
108
|
+
expect(screen.getByTestId('SvgReferenceAttribute')).toBeInTheDocument();
|
|
86
109
|
});
|
|
87
110
|
it("should render recommended icon if groupId === 'recommended'", function () {
|
|
88
|
-
|
|
89
|
-
expect(
|
|
90
|
-
expect(component.find(NestedAttrIcon)).toHaveLength(0);
|
|
91
|
-
expect(component.find(ReferenceAttrIcon)).toHaveLength(0);
|
|
92
|
-
expect(component.find(RecommendedIconWithTooltip)).toHaveLength(1);
|
|
111
|
+
setUp(__assign(__assign({}, defaultProps), { hideIcon: false, data: {}, groupId: 'recommended' }));
|
|
112
|
+
expect(screen.getByTestId('SvgRecommended')).toBeInTheDocument();
|
|
93
113
|
});
|
|
94
114
|
it('should not render icon if props.hideIcon === true', function () {
|
|
95
|
-
|
|
96
|
-
expect(
|
|
97
|
-
expect(component.find(NestedAttrIcon)).toHaveLength(0);
|
|
98
|
-
expect(component.find(ReferenceAttrIcon)).toHaveLength(0);
|
|
99
|
-
expect(component.find(RecommendedIconWithTooltip)).toHaveLength(0);
|
|
115
|
+
setUp(__assign(__assign({}, defaultProps), { hideIcon: true }));
|
|
116
|
+
expect(screen.queryByTestId('SvgSimpleAttribute')).not.toBeInTheDocument();
|
|
100
117
|
});
|
|
101
118
|
it('should render logo attribute icon', function () {
|
|
102
|
-
|
|
103
|
-
expect(
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
119
|
+
setUp(__assign(__assign({}, defaultProps), { LogoIcon: SomeLogoIcon }));
|
|
120
|
+
expect(getMuiIconByName('PlayArrow')).toBeInTheDocument();
|
|
121
|
+
});
|
|
122
|
+
it('should call onClick props with checked state and attributeTypes', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
123
|
+
var onClick, data, groupId, _a, user, rerender;
|
|
124
|
+
return __generator(this, function (_b) {
|
|
125
|
+
switch (_b.label) {
|
|
126
|
+
case 0:
|
|
127
|
+
onClick = jest.fn();
|
|
128
|
+
data = {};
|
|
129
|
+
groupId = 'tesGroupId';
|
|
130
|
+
_a = setUp(__assign(__assign({}, defaultProps), { data: data, onClick: onClick, groupId: groupId })), user = _a.user, rerender = _a.rerender;
|
|
131
|
+
return [4 /*yield*/, user.click(screen.getByRole('menuitem'))];
|
|
132
|
+
case 1:
|
|
133
|
+
_b.sent();
|
|
134
|
+
expect(onClick).toBeCalledWith(data, true, groupId);
|
|
135
|
+
rerender(React.createElement(AttributeListItem, __assign({}, defaultProps, { data: data, onClick: onClick, groupId: groupId, checked: true })));
|
|
136
|
+
return [4 /*yield*/, user.click(screen.getByRole('menuitem'))];
|
|
137
|
+
case 2:
|
|
138
|
+
_b.sent();
|
|
139
|
+
expect(onClick).toBeCalledWith(data, false, groupId);
|
|
140
|
+
return [2 /*return*/];
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
}); });
|
|
118
144
|
it('should hide checkbox when hideCheckBox is set', function () {
|
|
119
|
-
|
|
120
|
-
expect(
|
|
121
|
-
});
|
|
122
|
-
it('should unable click for nested attribute when hideCheckBox is set', function () {
|
|
123
|
-
var
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
145
|
+
setUp(__assign(__assign({}, defaultProps), { hideCheckBox: true }));
|
|
146
|
+
expect(screen.queryByRole('checkbox')).not.toBeInTheDocument();
|
|
147
|
+
});
|
|
148
|
+
it('should unable click for nested attribute when hideCheckBox is set', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
149
|
+
var onClick, user;
|
|
150
|
+
return __generator(this, function (_a) {
|
|
151
|
+
switch (_a.label) {
|
|
152
|
+
case 0:
|
|
153
|
+
onClick = jest.fn();
|
|
154
|
+
user = setUp(__assign(__assign({}, defaultProps), { onClick: onClick, data: {
|
|
155
|
+
attrType: {
|
|
156
|
+
type: 'Nested',
|
|
157
|
+
name: 'name',
|
|
158
|
+
uri: 'uri'
|
|
159
|
+
}
|
|
160
|
+
}, hideCheckBox: true })).user;
|
|
161
|
+
return [4 /*yield*/, user.click(screen.getByRole('menuitem'))];
|
|
162
|
+
case 1:
|
|
163
|
+
_a.sent();
|
|
164
|
+
expect(onClick).not.toBeCalled();
|
|
165
|
+
return [2 /*return*/];
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
}); });
|
|
169
|
+
it('should do not allow to click on attribute when notSelectable is true', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
170
|
+
var onClick, user, menuItem;
|
|
171
|
+
return __generator(this, function (_a) {
|
|
172
|
+
switch (_a.label) {
|
|
173
|
+
case 0:
|
|
174
|
+
onClick = jest.fn();
|
|
175
|
+
user = setUp(__assign(__assign({}, defaultProps), { onClick: onClick, data: {
|
|
176
|
+
attrType: {
|
|
177
|
+
type: 'Nested',
|
|
178
|
+
name: 'name',
|
|
179
|
+
uri: 'uri'
|
|
180
|
+
}
|
|
181
|
+
}, notSelectable: true })).user;
|
|
182
|
+
menuItem = screen.getByRole('menuitem');
|
|
183
|
+
return [4 /*yield*/, user.click(menuItem)];
|
|
184
|
+
case 1:
|
|
185
|
+
_a.sent();
|
|
186
|
+
expect(menuItem).toHaveClass('defaultCursor');
|
|
187
|
+
expect(onClick).not.toBeCalled();
|
|
188
|
+
expect(screen.getByRole('checkbox')).toBeDisabled();
|
|
189
|
+
return [2 /*return*/];
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
}); });
|
|
141
193
|
it('should render RequiredMark if isRequired=true', function () {
|
|
142
|
-
|
|
143
|
-
expect(
|
|
194
|
+
setUp(__assign(__assign({}, defaultProps), { isRequired: true }));
|
|
195
|
+
expect(screen.getByText('*')).toBeInTheDocument();
|
|
144
196
|
});
|
|
145
197
|
it('should disable notSelectable if disableNonSelectable=true', function () {
|
|
146
|
-
|
|
147
|
-
expect(screen.getByRole('checkbox')).
|
|
198
|
+
setUp(__assign(__assign({}, defaultProps), { isRequired: true, notSelectable: true, disableNonSelectable: true }));
|
|
199
|
+
expect(screen.getByRole('checkbox')).toBeDisabled();
|
|
148
200
|
});
|
|
149
201
|
});
|