@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
|
@@ -1,18 +1,37 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
1
12
|
import React from 'react';
|
|
2
|
-
import { mount, shallow } from 'enzyme';
|
|
3
13
|
import { BlobRenderer } from './BlobRenderer';
|
|
4
|
-
|
|
14
|
+
import { fireEvent, render, screen } from '@testing-library/react';
|
|
15
|
+
describe('BlobRenderer test', function () {
|
|
16
|
+
var defaultProps = {
|
|
17
|
+
value: 'testValue'
|
|
18
|
+
};
|
|
19
|
+
var setUp = function (props, wrapper) {
|
|
20
|
+
if (props === void 0) { props = defaultProps; }
|
|
21
|
+
return __assign({}, render(React.createElement(BlobRenderer, __assign({}, props)), { wrapper: wrapper }));
|
|
22
|
+
};
|
|
5
23
|
it('should render value', function () {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
expect(wrapper.html()).toContain(testValue);
|
|
24
|
+
setUp();
|
|
25
|
+
expect(screen.getByText(defaultProps.value)).toBeInTheDocument();
|
|
9
26
|
});
|
|
10
27
|
it('should stop propagation scroll event', function () {
|
|
11
|
-
var testValue = 'testValue';
|
|
12
28
|
var scrollHandler = jest.fn();
|
|
13
|
-
var
|
|
14
|
-
|
|
15
|
-
|
|
29
|
+
var scrollTestWrapper = function (_a) {
|
|
30
|
+
var children = _a.children;
|
|
31
|
+
return React.createElement("div", { onScroll: scrollHandler }, children);
|
|
32
|
+
};
|
|
33
|
+
setUp(defaultProps, scrollTestWrapper);
|
|
34
|
+
fireEvent.scroll(screen.getByText(defaultProps.value), { target: { scrollY: 100 } });
|
|
16
35
|
expect(scrollHandler).not.toHaveBeenCalled();
|
|
17
36
|
});
|
|
18
37
|
});
|
|
@@ -1,41 +1,95 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
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
|
+
};
|
|
1
48
|
import React from 'react';
|
|
2
|
-
import { mount } from 'enzyme';
|
|
3
|
-
import FormControlLabel from '@mui/material/FormControlLabel';
|
|
4
|
-
import { BooleanEditor } from './components/BooleanEditor';
|
|
5
49
|
import { BooleanRadioEditor } from './BooleanRadioEditor';
|
|
50
|
+
import { render, screen } from '@testing-library/react';
|
|
51
|
+
import userEvent from '@testing-library/user-event';
|
|
52
|
+
import { getMuiIconByName } from '../test-utils';
|
|
6
53
|
describe('BooleanRadioEditor', function () {
|
|
54
|
+
var setUp = function (props) {
|
|
55
|
+
if (props === void 0) { props = {}; }
|
|
56
|
+
var user = userEvent.setup();
|
|
57
|
+
return __assign({ user: user }, render(React.createElement(BooleanRadioEditor, __assign({}, props))));
|
|
58
|
+
};
|
|
7
59
|
it('should render two boolean editors with "Yes" and "No" labels', function () {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
expect(
|
|
11
|
-
|
|
12
|
-
expect(n.find(BooleanEditor)).toHaveLength(1);
|
|
13
|
-
});
|
|
14
|
-
expect(controls.at(0).prop('label')).toBe('Yes');
|
|
15
|
-
expect(controls.at(1).prop('label')).toBe('No');
|
|
16
|
-
});
|
|
17
|
-
it('should have radio buttons behaviour', function () {
|
|
18
|
-
var wrapper = mount(React.createElement(BooleanRadioEditor, null));
|
|
19
|
-
expect(wrapper.find(BooleanEditor).at(0).prop('value')).toBe(false);
|
|
20
|
-
expect(wrapper.find(BooleanEditor).at(1).prop('value')).toBe(false);
|
|
21
|
-
wrapper.setProps({ value: true });
|
|
22
|
-
expect(wrapper.find(BooleanEditor).at(0).prop('value')).toBe(true);
|
|
23
|
-
expect(wrapper.find(BooleanEditor).at(1).prop('value')).toBe(false);
|
|
24
|
-
});
|
|
25
|
-
it('should call props.onChange correctly on "Yes" input toggle', function () {
|
|
26
|
-
var onChange = jest.fn();
|
|
27
|
-
var wrapper = mount(React.createElement(BooleanRadioEditor, { onChange: onChange }));
|
|
28
|
-
var yesInput = wrapper.find(BooleanEditor).at(0);
|
|
29
|
-
yesInput.prop('onChange')(true);
|
|
30
|
-
yesInput.prop('onChange')(false);
|
|
31
|
-
expect(onChange.mock.calls).toEqual([[true], [false]]);
|
|
32
|
-
});
|
|
33
|
-
it('should call props.onChange correctly on "No" input toggle', function () {
|
|
34
|
-
var onChange = jest.fn();
|
|
35
|
-
var wrapper = mount(React.createElement(BooleanRadioEditor, { onChange: onChange }));
|
|
36
|
-
var yesInput = wrapper.find(BooleanEditor).at(1);
|
|
37
|
-
yesInput.prop('onChange')(true);
|
|
38
|
-
yesInput.prop('onChange')(false);
|
|
39
|
-
expect(onChange.mock.calls).toEqual([[false], [true]]);
|
|
60
|
+
setUp();
|
|
61
|
+
expect(screen.getAllByRole('checkbox')).toHaveLength(2);
|
|
62
|
+
expect(screen.getByLabelText('Yes'));
|
|
63
|
+
expect(screen.getByLabelText('No'));
|
|
40
64
|
});
|
|
65
|
+
it('should have radio buttons behaviour', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
66
|
+
var checkboxes;
|
|
67
|
+
return __generator(this, function (_a) {
|
|
68
|
+
setUp({ value: true });
|
|
69
|
+
checkboxes = screen.getAllByRole('checkbox');
|
|
70
|
+
expect(checkboxes[0]).toBeChecked();
|
|
71
|
+
expect(checkboxes[1]).not.toBeChecked();
|
|
72
|
+
expect(getMuiIconByName('CheckBox')).toBeInTheDocument();
|
|
73
|
+
return [2 /*return*/];
|
|
74
|
+
});
|
|
75
|
+
}); });
|
|
76
|
+
it('should call props.onChange correctly', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
77
|
+
var onChangeSpy, user;
|
|
78
|
+
return __generator(this, function (_a) {
|
|
79
|
+
switch (_a.label) {
|
|
80
|
+
case 0:
|
|
81
|
+
onChangeSpy = jest.fn();
|
|
82
|
+
user = setUp({ onChange: onChangeSpy }).user;
|
|
83
|
+
return [4 /*yield*/, user.click(screen.getByLabelText('Yes'))];
|
|
84
|
+
case 1:
|
|
85
|
+
_a.sent();
|
|
86
|
+
expect(onChangeSpy).toHaveBeenLastCalledWith(true);
|
|
87
|
+
return [4 /*yield*/, user.click(screen.getByLabelText('No'))];
|
|
88
|
+
case 2:
|
|
89
|
+
_a.sent();
|
|
90
|
+
expect(onChangeSpy).toHaveBeenLastCalledWith(false);
|
|
91
|
+
return [2 /*return*/];
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
}); });
|
|
41
95
|
});
|
|
@@ -9,105 +9,129 @@ 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 {
|
|
14
|
-
import
|
|
49
|
+
import { render, within } from '@testing-library/react';
|
|
50
|
+
import userEvent from '@testing-library/user-event';
|
|
15
51
|
import BubbleChartWithPercents, { BubbleChart } from './BubbleChart';
|
|
16
|
-
import { Legend, Tooltip } from 'recharts';
|
|
17
52
|
import { getChartItemColor } from '@reltio/mdm-sdk';
|
|
18
|
-
describe('BubbleChart', function () {
|
|
19
|
-
var
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
{
|
|
26
|
-
id: 'first',
|
|
27
|
-
type: 'square',
|
|
28
|
-
color: getChartItemColor('first'),
|
|
29
|
-
value: 'first (1%)'
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
id: 'second',
|
|
33
|
-
type: 'square',
|
|
34
|
-
color: getChartItemColor('second'),
|
|
35
|
-
value: 'second (2%)'
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
id: 'third',
|
|
39
|
-
type: 'square',
|
|
40
|
-
color: getChartItemColor('third'),
|
|
41
|
-
value: 'third (3%)'
|
|
42
|
-
}
|
|
43
|
-
];
|
|
44
|
-
var props = {
|
|
45
|
-
data: data,
|
|
53
|
+
describe('BubbleChart tests', function () {
|
|
54
|
+
var defaultProps = {
|
|
55
|
+
data: [
|
|
56
|
+
{ label: 'first', value: 1, percent: 1, group: '1' },
|
|
57
|
+
{ label: 'second', value: 2, percent: 2, group: '2' },
|
|
58
|
+
{ label: 'third', value: 3, percent: 3, group: '3' }
|
|
59
|
+
],
|
|
46
60
|
width: 600,
|
|
47
61
|
height: 300
|
|
48
62
|
};
|
|
63
|
+
var setUp = function (props) {
|
|
64
|
+
if (props === void 0) { props = defaultProps; }
|
|
65
|
+
var user = userEvent.setup();
|
|
66
|
+
return __assign({ user: user }, render(React.createElement(BubbleChart, __assign({}, props))));
|
|
67
|
+
};
|
|
49
68
|
it('should render svg with circles, Legend and Tooltip', function () {
|
|
50
|
-
var
|
|
51
|
-
var
|
|
52
|
-
expect(
|
|
53
|
-
expect(
|
|
54
|
-
|
|
55
|
-
expect(
|
|
56
|
-
expect(
|
|
69
|
+
var container = setUp().container;
|
|
70
|
+
var svg = container.querySelector('svg');
|
|
71
|
+
expect(svg).toHaveAttribute('height', "".concat(defaultProps.height));
|
|
72
|
+
expect(svg).toHaveAttribute('width', "".concat(defaultProps.width));
|
|
73
|
+
var circles = container.querySelectorAll('circle');
|
|
74
|
+
expect(circles).toHaveLength(3);
|
|
75
|
+
expect(container.querySelector('.recharts-tooltip-wrapper')).toBeInTheDocument();
|
|
76
|
+
var legendItems = container.querySelectorAll('.recharts-legend-wrapper .item');
|
|
77
|
+
expect(within(legendItems[0]).queryByText('first (1%)')).toBeInTheDocument();
|
|
78
|
+
expect(legendItems[0].firstChild).toHaveStyle({ background: getChartItemColor('first') });
|
|
79
|
+
expect(within(legendItems[1]).queryByText('second (2%)')).toBeInTheDocument();
|
|
80
|
+
expect(legendItems[1].firstChild).toHaveStyle({ background: getChartItemColor('second') });
|
|
81
|
+
expect(within(legendItems[2]).queryByText('third (3%)')).toBeInTheDocument();
|
|
82
|
+
expect(legendItems[2].firstChild).toHaveStyle({ background: getChartItemColor('third') });
|
|
57
83
|
});
|
|
58
84
|
it('should not render Legend when props.options.showLegend = false', function () {
|
|
59
|
-
var
|
|
60
|
-
|
|
85
|
+
var container = setUp(__assign(__assign({}, defaultProps), { options: {
|
|
86
|
+
showLegend: false
|
|
87
|
+
} })).container;
|
|
88
|
+
expect(container.querySelector('.recharts-legend-wrapper')).not.toBeInTheDocument();
|
|
61
89
|
});
|
|
62
|
-
it('should show Tooltip on dot hover and hide on dot leave', function () {
|
|
63
|
-
var
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
90
|
+
it('should show Tooltip on dot hover and hide on dot leave', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
91
|
+
var _a, user, container, circles, tootltip;
|
|
92
|
+
return __generator(this, function (_b) {
|
|
93
|
+
switch (_b.label) {
|
|
94
|
+
case 0:
|
|
95
|
+
_a = setUp(), user = _a.user, container = _a.container;
|
|
96
|
+
circles = container.querySelectorAll('circle');
|
|
97
|
+
return [4 /*yield*/, user.hover(circles[0])];
|
|
98
|
+
case 1:
|
|
99
|
+
_b.sent();
|
|
100
|
+
tootltip = container.querySelector('.recharts-tooltip-wrapper');
|
|
101
|
+
expect(tootltip).toBeVisible();
|
|
102
|
+
expect(within(tootltip).getByText('third')).toBeInTheDocument();
|
|
103
|
+
return [4 /*yield*/, user.unhover(circles[0])];
|
|
104
|
+
case 2:
|
|
105
|
+
_b.sent();
|
|
106
|
+
expect(tootltip).not.toBeVisible();
|
|
107
|
+
expect(within(tootltip).queryByText('third')).not.toBeInTheDocument();
|
|
108
|
+
return [2 /*return*/];
|
|
109
|
+
}
|
|
77
110
|
});
|
|
78
|
-
|
|
79
|
-
|
|
111
|
+
}); });
|
|
112
|
+
it('should call props.onItemClick on circle click', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
113
|
+
var onItemClickSpy, _a, user, container;
|
|
114
|
+
return __generator(this, function (_b) {
|
|
115
|
+
switch (_b.label) {
|
|
116
|
+
case 0:
|
|
117
|
+
onItemClickSpy = jest.fn();
|
|
118
|
+
_a = setUp(__assign(__assign({}, defaultProps), { onItemClick: onItemClickSpy })), user = _a.user, container = _a.container;
|
|
119
|
+
return [4 /*yield*/, user.click(container.querySelector('circle'))];
|
|
120
|
+
case 1:
|
|
121
|
+
_b.sent();
|
|
122
|
+
expect(onItemClickSpy).toHaveBeenCalledWith('3');
|
|
123
|
+
return [2 /*return*/];
|
|
124
|
+
}
|
|
80
125
|
});
|
|
81
|
-
});
|
|
82
|
-
it('should call props.onItemClick on circle click', function () {
|
|
83
|
-
var onItemClick = jest.fn();
|
|
84
|
-
var wrapper = shallow(React.createElement(BubbleChart, __assign({}, props, { onItemClick: onItemClick })));
|
|
85
|
-
var circle = wrapper.find('circle').first();
|
|
86
|
-
circle.simulate('click');
|
|
87
|
-
expect(onItemClick).toBeCalledWith('3');
|
|
88
|
-
});
|
|
126
|
+
}); });
|
|
89
127
|
it('should render legend with percents correctly', function () {
|
|
90
|
-
var
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
id: 'second',
|
|
99
|
-
type: 'square',
|
|
100
|
-
color: getChartItemColor('second'),
|
|
101
|
-
value: 'second (33.3%)'
|
|
102
|
-
},
|
|
103
|
-
{
|
|
104
|
-
id: 'third',
|
|
105
|
-
type: 'square',
|
|
106
|
-
color: getChartItemColor('third'),
|
|
107
|
-
value: 'third (50%)'
|
|
108
|
-
}
|
|
109
|
-
];
|
|
110
|
-
var wrapper = mount(React.createElement(BubbleChartWithPercents, __assign({}, props)));
|
|
111
|
-
expect(wrapper.find(Legend).prop('payload')).toEqual(legendPayload);
|
|
128
|
+
var container = render(React.createElement(BubbleChartWithPercents, __assign({}, defaultProps))).container;
|
|
129
|
+
var legendItems = container.querySelectorAll('.recharts-legend-wrapper .item');
|
|
130
|
+
expect(within(legendItems[0]).queryByText('first (16.7%)')).toBeInTheDocument();
|
|
131
|
+
expect(legendItems[0].firstChild).toHaveStyle({ background: getChartItemColor('first') });
|
|
132
|
+
expect(within(legendItems[1]).queryByText('second (33.3%)')).toBeInTheDocument();
|
|
133
|
+
expect(legendItems[1].firstChild).toHaveStyle({ background: getChartItemColor('second') });
|
|
134
|
+
expect(within(legendItems[2]).queryByText('third (50%)')).toBeInTheDocument();
|
|
135
|
+
expect(legendItems[2].firstChild).toHaveStyle({ background: getChartItemColor('third') });
|
|
112
136
|
});
|
|
113
137
|
});
|
|
@@ -9,49 +9,108 @@ 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 { shallow } from 'enzyme';
|
|
14
49
|
import { getChartItemColor } from '@reltio/mdm-sdk';
|
|
15
|
-
import
|
|
50
|
+
import userEvent from '@testing-library/user-event';
|
|
51
|
+
import { render, screen, within } from '@testing-library/react';
|
|
16
52
|
import { CloudChart } from './CloudChart';
|
|
17
|
-
describe('CloudChart', function () {
|
|
18
|
-
var
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
data: data,
|
|
53
|
+
describe('CloudChart tests', function () {
|
|
54
|
+
var defaultProps = {
|
|
55
|
+
data: [
|
|
56
|
+
{ label: 'first', value: 1, percent: 1, group: '1' },
|
|
57
|
+
{ label: 'second', value: 2, percent: 2, group: '2' },
|
|
58
|
+
{ label: 'third', value: 3, percent: 3, group: '3' }
|
|
59
|
+
],
|
|
25
60
|
width: 600,
|
|
26
61
|
height: 300
|
|
27
62
|
};
|
|
63
|
+
var setUp = function (props) {
|
|
64
|
+
if (props === void 0) { props = defaultProps; }
|
|
65
|
+
var user = userEvent.setup();
|
|
66
|
+
return __assign({ user: user }, render(React.createElement(CloudChart, __assign({}, props))));
|
|
67
|
+
};
|
|
28
68
|
it('should render svg with text and Tooltip', function () {
|
|
29
|
-
var
|
|
30
|
-
var
|
|
31
|
-
expect(
|
|
32
|
-
expect(
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
expect(
|
|
36
|
-
expect(el.prop('fill')).toEqual(getChartItemColor(data[i].label));
|
|
69
|
+
var container = setUp().container;
|
|
70
|
+
var svg = container.querySelector('svg');
|
|
71
|
+
expect(svg).toHaveAttribute('height', "".concat(defaultProps.height));
|
|
72
|
+
expect(svg).toHaveAttribute('width', "".concat(defaultProps.width));
|
|
73
|
+
defaultProps.data.forEach(function (data) {
|
|
74
|
+
var text = screen.getByText(data.label);
|
|
75
|
+
expect(text).toHaveAttribute('fill', getChartItemColor(data.label));
|
|
37
76
|
});
|
|
38
|
-
expect(
|
|
39
|
-
});
|
|
40
|
-
it('should show Tooltip on text hover and hide on text leave', function () {
|
|
41
|
-
var wrapper = shallow(React.createElement(CloudChart, __assign({}, props)));
|
|
42
|
-
expect(wrapper.find(Tooltip).prop('active')).toBe(false);
|
|
43
|
-
var text = wrapper.find('svg').find('text').at(0);
|
|
44
|
-
text.simulate('mouseEnter');
|
|
45
|
-
expect(wrapper.find(Tooltip).prop('active')).toBe(true);
|
|
46
|
-
expect(wrapper.find(Tooltip).prop('label')).toBe(text.text());
|
|
47
|
-
text.simulate('mouseLeave');
|
|
48
|
-
expect(wrapper.find(Tooltip).prop('active')).toBe(false);
|
|
49
|
-
});
|
|
50
|
-
it('should call props.onItemClick on text click', function () {
|
|
51
|
-
var onItemClick = jest.fn();
|
|
52
|
-
var wrapper = shallow(React.createElement(CloudChart, __assign({}, props, { onItemClick: onItemClick })));
|
|
53
|
-
var text = wrapper.find('text').first();
|
|
54
|
-
text.simulate('click');
|
|
55
|
-
expect(onItemClick).toBeCalledWith('1');
|
|
77
|
+
expect(container.querySelector('.recharts-tooltip-wrapper')).toBeInTheDocument();
|
|
56
78
|
});
|
|
79
|
+
it('should show Tooltip on text hover and hide on text leave', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
80
|
+
var _a, user, container, text, tootltip;
|
|
81
|
+
return __generator(this, function (_b) {
|
|
82
|
+
switch (_b.label) {
|
|
83
|
+
case 0:
|
|
84
|
+
_a = setUp(), user = _a.user, container = _a.container;
|
|
85
|
+
text = screen.getByText('first');
|
|
86
|
+
return [4 /*yield*/, user.hover(text)];
|
|
87
|
+
case 1:
|
|
88
|
+
_b.sent();
|
|
89
|
+
tootltip = container.querySelector('.recharts-tooltip-wrapper');
|
|
90
|
+
expect(tootltip).toBeVisible();
|
|
91
|
+
expect(within(tootltip).getByText('first')).toBeInTheDocument();
|
|
92
|
+
return [4 /*yield*/, user.unhover(text)];
|
|
93
|
+
case 2:
|
|
94
|
+
_b.sent();
|
|
95
|
+
expect(tootltip).not.toBeVisible();
|
|
96
|
+
expect(within(tootltip).queryByText('first')).not.toBeInTheDocument();
|
|
97
|
+
return [2 /*return*/];
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
}); });
|
|
101
|
+
it('should call props.onItemClick on text click', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
102
|
+
var onItemClickSpy, user;
|
|
103
|
+
return __generator(this, function (_a) {
|
|
104
|
+
switch (_a.label) {
|
|
105
|
+
case 0:
|
|
106
|
+
onItemClickSpy = jest.fn();
|
|
107
|
+
user = setUp(__assign(__assign({}, defaultProps), { onItemClick: onItemClickSpy })).user;
|
|
108
|
+
return [4 /*yield*/, user.click(screen.getByText('first'))];
|
|
109
|
+
case 1:
|
|
110
|
+
_a.sent();
|
|
111
|
+
expect(onItemClickSpy).toHaveBeenCalledWith('1');
|
|
112
|
+
return [2 /*return*/];
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
}); });
|
|
57
116
|
});
|