@reltio/components 1.4.1905 → 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/cjs/ConnectionRelationTypeSelector/ConnectionRelationTypeSelector.d.ts +3 -1
- package/cjs/ReactSortableTree/ReactSortableTree.js +2 -7
- package/cjs/RelationTypeSelector/RelationTypeSelector.d.ts +3 -1
- package/cjs/types/index.d.ts +1 -1
- 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/esm/ConnectionRelationTypeSelector/ConnectionRelationTypeSelector.d.ts +3 -1
- package/esm/ReactSortableTree/ReactSortableTree.js +2 -7
- package/esm/RelationTypeSelector/RelationTypeSelector.d.ts +3 -1
- package/esm/types/index.d.ts +1 -1
- package/package.json +2 -2
- 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
|
@@ -10,47 +10,80 @@ var __assign = (this && this.__assign) || function () {
|
|
|
10
10
|
return __assign.apply(this, arguments);
|
|
11
11
|
};
|
|
12
12
|
import React from 'react';
|
|
13
|
-
import { mount } from 'enzyme';
|
|
14
13
|
import { Mode } from '@reltio/mdm-sdk';
|
|
15
14
|
import { AttributesView } from './AttributesView';
|
|
16
|
-
import { ReadOnlyAttributesView } from '../ReadOnlyAttributesView';
|
|
17
|
-
import { EditModeAttributesView } from '../EditModeAttributesView';
|
|
18
|
-
import { EntityContext } from '../contexts/EntityContext';
|
|
19
15
|
import { MdmModuleProvider } from '../contexts/MdmModuleContext';
|
|
20
|
-
|
|
21
|
-
ReadOnlyAttributesView: function () { return null; }
|
|
22
|
-
}); });
|
|
23
|
-
jest.mock('../EditModeAttributesView', function () { return ({
|
|
24
|
-
EditModeAttributesView: function () { return null; }
|
|
25
|
-
}); });
|
|
26
|
-
jest.mock('../contexts/EntityContext', function () { return ({
|
|
27
|
-
EntityContext: { Provider: function (_a) {
|
|
28
|
-
var children = _a.children;
|
|
29
|
-
return children;
|
|
30
|
-
} }
|
|
31
|
-
}); });
|
|
32
|
-
var setUp = function (props) {
|
|
33
|
-
return mount(React.createElement(MdmModuleProvider, { values: { entityWithDiff: undefined, mode: undefined } },
|
|
34
|
-
React.createElement(AttributesView, __assign({}, props))));
|
|
35
|
-
};
|
|
16
|
+
import { render, screen } from '@testing-library/react';
|
|
36
17
|
describe('AttributesView tests', function () {
|
|
18
|
+
var entity = {
|
|
19
|
+
type: 'configuration/entityTypes/HCP',
|
|
20
|
+
uri: 'entities/02ZRRE9',
|
|
21
|
+
attributes: {
|
|
22
|
+
FirstName: [
|
|
23
|
+
{
|
|
24
|
+
type: 'configuration/entityTypes/HCP/attributes/FirstName',
|
|
25
|
+
ov: true,
|
|
26
|
+
value: 'nameValue',
|
|
27
|
+
uri: 'entities/02ZRRE9/attributes/FirstName/15p60Tel'
|
|
28
|
+
}
|
|
29
|
+
]
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
var metadata = {
|
|
33
|
+
entityTypes: [
|
|
34
|
+
{
|
|
35
|
+
uri: 'configuration/entityTypes/HCP',
|
|
36
|
+
attributes: [
|
|
37
|
+
{
|
|
38
|
+
uri: 'configuration/entityTypes/HCP/attributes/FirstName',
|
|
39
|
+
type: 'String',
|
|
40
|
+
name: 'FirstName',
|
|
41
|
+
label: 'First Name',
|
|
42
|
+
access: ['READ', 'CREATE', 'UPDATE', 'INITIATE_CHANGE_REQUEST']
|
|
43
|
+
}
|
|
44
|
+
]
|
|
45
|
+
}
|
|
46
|
+
]
|
|
47
|
+
};
|
|
48
|
+
var actions = {
|
|
49
|
+
removeAttribute: function () { }
|
|
50
|
+
};
|
|
51
|
+
var mdmDefaultValues = {
|
|
52
|
+
metadata: metadata,
|
|
53
|
+
modifiedEntities: { 'entities/02ZRRE9': entity },
|
|
54
|
+
dependentLookups: { editors: {}, structure: {}, initedTypeUris: [] }
|
|
55
|
+
};
|
|
56
|
+
var setUp = function (props, mdmValues) {
|
|
57
|
+
if (props === void 0) { props = {}; }
|
|
58
|
+
if (mdmValues === void 0) { mdmValues = mdmDefaultValues; }
|
|
59
|
+
var Providers = function (_a) {
|
|
60
|
+
var children = _a.children;
|
|
61
|
+
return (React.createElement(MdmModuleProvider, { values: mdmValues, actions: actions }, children));
|
|
62
|
+
};
|
|
63
|
+
return render(React.createElement(AttributesView, __assign({}, props)), { wrapper: Providers });
|
|
64
|
+
};
|
|
37
65
|
it('should render ReadOnlyAttributesView in read mode if mode is "viewing"', function () {
|
|
38
|
-
|
|
39
|
-
expect(
|
|
66
|
+
setUp({ mode: Mode.Viewing, entity: entity });
|
|
67
|
+
expect(screen.getByText('nameValue')).toBeInTheDocument();
|
|
68
|
+
});
|
|
69
|
+
it('should render ReadOnlyAttributesView in read mode if mode is "viewing" in context', function () {
|
|
70
|
+
setUp({ entity: entity }, __assign(__assign({}, mdmDefaultValues), { mode: Mode.Viewing }));
|
|
71
|
+
expect(screen.getByText('nameValue')).toBeInTheDocument();
|
|
72
|
+
});
|
|
73
|
+
it('should render EditModeAttributesView in read mode if mode is "editing"', function () {
|
|
74
|
+
setUp({ mode: Mode.Editing, entity: entity });
|
|
75
|
+
expect(screen.getByRole('textbox')).toHaveValue('nameValue');
|
|
40
76
|
});
|
|
41
|
-
it('should render EditModeAttributesView in
|
|
42
|
-
|
|
43
|
-
expect(
|
|
77
|
+
it('should render EditModeAttributesView in read mode if mode is "editing" in context', function () {
|
|
78
|
+
setUp({ entity: entity }, __assign(__assign({}, mdmDefaultValues), { mode: Mode.Editing }));
|
|
79
|
+
expect(screen.getByRole('textbox')).toHaveValue('nameValue');
|
|
44
80
|
});
|
|
45
|
-
it('should render EditModeAttributesView in
|
|
46
|
-
|
|
47
|
-
expect(
|
|
81
|
+
it('should render EditModeAttributesView in read mode if mode is "suggesting"', function () {
|
|
82
|
+
setUp({ mode: Mode.Suggesting, entity: entity });
|
|
83
|
+
expect(screen.getByRole('textbox')).toHaveValue('nameValue');
|
|
48
84
|
});
|
|
49
|
-
it('should
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
var contextProvider = component.find(EntityContext.Provider);
|
|
53
|
-
expect(contextProvider.prop('value')).toBe(entity);
|
|
54
|
-
expect(contextProvider.childAt(0)).toEqual(component.find(ReadOnlyAttributesView));
|
|
85
|
+
it('should render EditModeAttributesView in read mode if mode is "suggesting" in context', function () {
|
|
86
|
+
setUp({ entity: entity }, __assign(__assign({}, mdmDefaultValues), { mode: Mode.Suggesting }));
|
|
87
|
+
expect(screen.getByRole('textbox')).toHaveValue('nameValue');
|
|
55
88
|
});
|
|
56
89
|
});
|
|
@@ -9,11 +9,46 @@ 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 { mount } from 'enzyme';
|
|
14
49
|
import AutoSizeList from './AutoSizeList';
|
|
15
|
-
import { VariableSizeList as List } from 'react-window';
|
|
16
50
|
import { delayPromise } from '../test-utils';
|
|
51
|
+
import { render, screen } from '@testing-library/react';
|
|
17
52
|
jest.mock('resize-observer-polyfill', function () { return ({
|
|
18
53
|
__esModule: true,
|
|
19
54
|
default: jest.fn().mockImplementation(function (onResize) {
|
|
@@ -26,74 +61,61 @@ jest.mock('resize-observer-polyfill', function () { return ({
|
|
|
26
61
|
})
|
|
27
62
|
}); });
|
|
28
63
|
describe('AutoSizeList tests', function () {
|
|
29
|
-
var
|
|
64
|
+
var defaultProps = {
|
|
30
65
|
width: 100,
|
|
31
66
|
height: 100,
|
|
32
67
|
data: [1, 2, 3],
|
|
33
68
|
defaultItemSize: 50,
|
|
34
|
-
children: function () {
|
|
69
|
+
children: function (_a) {
|
|
70
|
+
var data = _a.data, index = _a.index;
|
|
71
|
+
return "child-".concat(data[index]);
|
|
72
|
+
}
|
|
35
73
|
};
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
wrapper.update();
|
|
57
|
-
listItems = wrapper.find(List).find('.item');
|
|
58
|
-
expect(listItems).toHaveLength(itemCount);
|
|
59
|
-
listItems.forEach(function (item) {
|
|
60
|
-
expect(item.childAt(0).prop('style')).toEqual({
|
|
61
|
-
visibility: undefined
|
|
62
|
-
});
|
|
63
|
-
});
|
|
64
|
-
});
|
|
65
|
-
});
|
|
66
|
-
it('should not add style.visibility to items if props.showNotMeasuredItems is true', function () {
|
|
67
|
-
var wrapper = mount(React.createElement(AutoSizeList, __assign({}, props, { showNotMeasuredItems: true })));
|
|
68
|
-
var itemCount = props.data.length;
|
|
69
|
-
var list = wrapper.find(List);
|
|
70
|
-
expect(list.props()).toMatchObject({
|
|
71
|
-
width: props.width,
|
|
72
|
-
height: props.height,
|
|
73
|
-
itemCount: itemCount,
|
|
74
|
-
itemData: props.data
|
|
75
|
-
});
|
|
76
|
-
var listItems = list.find('.item');
|
|
77
|
-
expect(listItems).toHaveLength(itemCount);
|
|
78
|
-
listItems.forEach(function (item) {
|
|
79
|
-
expect(item.childAt(0).prop('style')).toBeUndefined();
|
|
74
|
+
var setUp = function (props) {
|
|
75
|
+
if (props === void 0) { props = defaultProps; }
|
|
76
|
+
return render(React.createElement(AutoSizeList, __assign({}, props)));
|
|
77
|
+
};
|
|
78
|
+
it('should render correctly', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
79
|
+
return __generator(this, function (_a) {
|
|
80
|
+
switch (_a.label) {
|
|
81
|
+
case 0:
|
|
82
|
+
setUp();
|
|
83
|
+
expect(screen.getByText('child-1')).toHaveStyle({ visibility: 'hidden' });
|
|
84
|
+
expect(screen.getByText('child-2')).toHaveStyle({ visibility: 'hidden' });
|
|
85
|
+
expect(screen.getByText('child-3')).toHaveStyle({ visibility: 'hidden' });
|
|
86
|
+
return [4 /*yield*/, delayPromise(100)];
|
|
87
|
+
case 1:
|
|
88
|
+
_a.sent();
|
|
89
|
+
expect(screen.getByText('child-1')).toHaveStyle({ visibility: 'visible' });
|
|
90
|
+
expect(screen.getByText('child-2')).toHaveStyle({ visibility: 'visible' });
|
|
91
|
+
expect(screen.getByText('child-3')).toHaveStyle({ visibility: 'visible' });
|
|
92
|
+
return [2 /*return*/];
|
|
93
|
+
}
|
|
80
94
|
});
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
95
|
+
}); });
|
|
96
|
+
it('should not add style.visibility to items if props.showNotMeasuredItems is true', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
97
|
+
return __generator(this, function (_a) {
|
|
98
|
+
switch (_a.label) {
|
|
99
|
+
case 0:
|
|
100
|
+
setUp(__assign(__assign({}, defaultProps), { showNotMeasuredItems: true }));
|
|
101
|
+
expect(screen.getByText('child-1')).not.toHaveAttribute('visibility');
|
|
102
|
+
expect(screen.getByText('child-2')).not.toHaveAttribute('visibility');
|
|
103
|
+
expect(screen.getByText('child-3')).not.toHaveAttribute('visibility');
|
|
104
|
+
return [4 /*yield*/, delayPromise(100)];
|
|
105
|
+
case 1:
|
|
106
|
+
_a.sent();
|
|
107
|
+
expect(screen.getByText('child-1')).not.toHaveAttribute('visibility');
|
|
108
|
+
expect(screen.getByText('child-2')).not.toHaveAttribute('visibility');
|
|
109
|
+
expect(screen.getByText('child-3')).not.toHaveAttribute('visibility');
|
|
110
|
+
return [2 /*return*/];
|
|
111
|
+
}
|
|
90
112
|
});
|
|
91
|
-
});
|
|
113
|
+
}); });
|
|
92
114
|
it('should support props.listRef', function () {
|
|
93
115
|
var listRef = {
|
|
94
116
|
current: undefined
|
|
95
117
|
};
|
|
96
|
-
|
|
118
|
+
setUp(__assign(__assign({}, defaultProps), { listRef: listRef }));
|
|
97
119
|
expect(listRef.current.scrollTo).toBeDefined();
|
|
98
120
|
});
|
|
99
121
|
});
|
|
@@ -35,39 +35,23 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
35
35
|
}
|
|
36
36
|
};
|
|
37
37
|
import React from 'react';
|
|
38
|
-
import {
|
|
39
|
-
import
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
var ActionButton = function (_a) {
|
|
43
|
-
var mode = _a.mode, onMenuClose = _a.onMenuClose, testProp = _a.testProp;
|
|
44
|
-
return React.createElement("div", { "data-reltio-id": "action-button", "data-mode": mode, "data-test": testProp, onClick: onMenuClose });
|
|
45
|
-
};
|
|
46
|
-
var item = {
|
|
47
|
-
ActionButton: ActionButton,
|
|
48
|
-
show: true,
|
|
49
|
-
testProp: 'testProp'
|
|
50
|
-
};
|
|
51
|
-
it('should render main parts', function () {
|
|
52
|
-
render(React.createElement(MenuItemRenderer, { item: item }));
|
|
53
|
-
var button = screen.getByTestId('action-button');
|
|
54
|
-
expect(button).toBeInTheDocument();
|
|
55
|
-
expect(button).toHaveAttribute('data-mode', 'menuItem');
|
|
56
|
-
expect(button).toHaveAttribute('data-test', 'testProp');
|
|
57
|
-
});
|
|
58
|
-
it('should call onMenuClose on button click', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
59
|
-
var onMenuClose;
|
|
38
|
+
import { AvatarWithFallback } from './AvatarWithFallback';
|
|
39
|
+
import { fireEvent, render, screen } from '@testing-library/react';
|
|
40
|
+
describe('Avatar with fallback suite', function () {
|
|
41
|
+
it('should show icon if icon url is provided', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
60
42
|
return __generator(this, function (_a) {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
render(React.createElement(MenuItemRenderer, { item: item, onMenuClose: onMenuClose }));
|
|
65
|
-
return [4 /*yield*/, userEvent.click(screen.getByTestId('action-button'))];
|
|
66
|
-
case 1:
|
|
67
|
-
_a.sent();
|
|
68
|
-
expect(onMenuClose).toHaveBeenCalled();
|
|
69
|
-
return [2 /*return*/];
|
|
70
|
-
}
|
|
43
|
+
render(React.createElement(AvatarWithFallback, { icon: "icon" }));
|
|
44
|
+
expect(screen.getByRole('img')).toHaveAttribute('src', 'icon');
|
|
45
|
+
return [2 /*return*/];
|
|
71
46
|
});
|
|
72
47
|
}); });
|
|
48
|
+
it('should show text if icon url is not provided', function () {
|
|
49
|
+
render(React.createElement(AvatarWithFallback, { avatarText: "text" }));
|
|
50
|
+
expect(screen.getByText('text')).toBeInTheDocument();
|
|
51
|
+
});
|
|
52
|
+
it('should show text if error has happened', function () {
|
|
53
|
+
render(React.createElement(AvatarWithFallback, { icon: "icon", avatarText: "text" }));
|
|
54
|
+
fireEvent.error(screen.getByRole('img'));
|
|
55
|
+
expect(screen.getByText('text')).toBeInTheDocument();
|
|
56
|
+
});
|
|
73
57
|
});
|
|
@@ -1,3 +1,14 @@
|
|
|
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
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
13
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
14
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -34,84 +45,136 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
34
45
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
46
|
}
|
|
36
47
|
};
|
|
48
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
49
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
50
|
+
if (ar || !(i in from)) {
|
|
51
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
52
|
+
ar[i] = from[i];
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
56
|
+
};
|
|
37
57
|
import React from 'react';
|
|
38
|
-
import { shallow, mount } from 'enzyme';
|
|
39
|
-
import { BarChart as BarChartWidget, CartesianGrid, Tooltip, Bar, XAxis, YAxis } from 'recharts';
|
|
40
58
|
import { BarChart } from './BarChart';
|
|
59
|
+
import { render, within } from '@testing-library/react';
|
|
60
|
+
import userEvent from '@testing-library/user-event';
|
|
41
61
|
describe('BarChart', function () {
|
|
42
|
-
var
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
62
|
+
var defaultProps = {
|
|
63
|
+
data: [
|
|
64
|
+
{ label: 'first', value: 10, group: '1' },
|
|
65
|
+
{ label: 'second', value: 20, group: '2' },
|
|
66
|
+
{ label: 'third', value: 30, group: '3' }
|
|
67
|
+
],
|
|
68
|
+
width: 100,
|
|
69
|
+
height: 200
|
|
70
|
+
};
|
|
71
|
+
var setUp = function (props) {
|
|
72
|
+
if (props === void 0) { props = defaultProps; }
|
|
73
|
+
var user = userEvent.setup();
|
|
74
|
+
return __assign({ user: user }, render(React.createElement(BarChart, __assign({}, props))));
|
|
75
|
+
};
|
|
49
76
|
it('should render BarChartWidget', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
50
|
-
var
|
|
77
|
+
var container, chart, cartesianGrid, cartesianGridLines, xAxis, xAxisLine, xAxisTicks, yAxis, yAxisLine, yAxisTicks, barRectangles;
|
|
51
78
|
return __generator(this, function (_a) {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
expect(
|
|
57
|
-
expect(
|
|
58
|
-
expect(
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
expect(
|
|
62
|
-
expect(
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
79
|
+
container = setUp().container;
|
|
80
|
+
chart = container.querySelector('.recharts-surface');
|
|
81
|
+
expect(chart).toHaveAttribute('width', "".concat(defaultProps.width));
|
|
82
|
+
expect(chart).toHaveAttribute('height', "".concat(defaultProps.height));
|
|
83
|
+
expect(container.querySelector('.recharts-cartesian-grid-vertical')).toBeInTheDocument();
|
|
84
|
+
expect(container.querySelector('.recharts-cartesian-grid-horizontal')).toBeInTheDocument();
|
|
85
|
+
expect(container.querySelector('.recharts-tooltip-wrapper')).toBeInTheDocument();
|
|
86
|
+
cartesianGrid = container.querySelector('.recharts-cartesian-grid');
|
|
87
|
+
cartesianGridLines = cartesianGrid.querySelectorAll('line');
|
|
88
|
+
expect(cartesianGrid).toBeInTheDocument();
|
|
89
|
+
expect(cartesianGridLines).toHaveLength(13);
|
|
90
|
+
cartesianGridLines.forEach(function (line) {
|
|
91
|
+
expect(line).toHaveAttribute('stroke', '#666');
|
|
92
|
+
expect(line).toHaveAttribute('stroke-dasharray', '3 3');
|
|
93
|
+
expect(line).toHaveAttribute('stroke-opacity', '0.4');
|
|
94
|
+
});
|
|
95
|
+
xAxis = container.querySelector('.recharts-xAxis');
|
|
96
|
+
xAxisLine = xAxis.querySelector('.recharts-cartesian-axis-line');
|
|
97
|
+
xAxisTicks = xAxis.querySelectorAll('.recharts-cartesian-axis-tick');
|
|
98
|
+
expect(xAxis).toBeInTheDocument();
|
|
99
|
+
expect(xAxisLine).toBeInTheDocument();
|
|
100
|
+
expect(xAxisLine).toHaveAttribute('text-anchor', 'middle');
|
|
101
|
+
expect(xAxisLine).toHaveAttribute('angle', '0');
|
|
102
|
+
expect(xAxisTicks).toHaveLength(3);
|
|
103
|
+
xAxisTicks.forEach(function (xAxisTick, index) {
|
|
104
|
+
within(xAxisTick).getByText(defaultProps.data[index].label);
|
|
105
|
+
});
|
|
106
|
+
yAxis = container.querySelector('.recharts-yAxis');
|
|
107
|
+
yAxisLine = yAxis.querySelector('.recharts-cartesian-axis-line');
|
|
108
|
+
yAxisTicks = yAxis.querySelectorAll('.recharts-cartesian-axis-tick');
|
|
109
|
+
expect(yAxis).toBeInTheDocument();
|
|
110
|
+
expect(yAxisLine).toBeInTheDocument();
|
|
111
|
+
expect(yAxisTicks).toHaveLength(8);
|
|
112
|
+
within(yAxisTicks[0]).getByText('0');
|
|
113
|
+
within(yAxisTicks[1]).getByText('5');
|
|
114
|
+
within(yAxisTicks[2]).getByText('10');
|
|
115
|
+
within(yAxisTicks[3]).getByText('15');
|
|
116
|
+
within(yAxisTicks[4]).getByText('20');
|
|
117
|
+
within(yAxisTicks[5]).getByText('25');
|
|
118
|
+
within(yAxisTicks[6]).getByText('30');
|
|
119
|
+
within(yAxisTicks[7]).getByText('35');
|
|
120
|
+
barRectangles = container.querySelectorAll('.recharts-bar-rectangle');
|
|
121
|
+
expect(barRectangles).toHaveLength(defaultProps.data.length);
|
|
66
122
|
return [2 /*return*/];
|
|
67
123
|
});
|
|
68
124
|
}); });
|
|
69
125
|
it('should render horizontal BarChartWidget', function () {
|
|
70
|
-
var
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
expect(
|
|
75
|
-
expect(wrapper.find(CartesianGrid)).toHaveLength(1);
|
|
76
|
-
expect(wrapper.find(Tooltip)).toHaveLength(1);
|
|
77
|
-
expect(bar).toHaveLength(1);
|
|
78
|
-
expect(xAxis).toHaveLength(1);
|
|
79
|
-
expect(wrapper.find(YAxis)).toHaveLength(1);
|
|
80
|
-
expect(barChart.prop('layout')).toBe('vertical');
|
|
81
|
-
expect(bar.prop('fill')).toBe(horizontalBarColor);
|
|
82
|
-
expect(xAxis.prop('angle')).toBe(0);
|
|
83
|
-
expect(xAxis.prop('textAnchor')).toBe('middle');
|
|
126
|
+
var container = setUp(__assign(__assign({}, defaultProps), { options: {
|
|
127
|
+
isHorizontal: true
|
|
128
|
+
} })).container;
|
|
129
|
+
expect(container.querySelector('.recharts-cartesian-grid-vertical')).not.toBeInTheDocument();
|
|
130
|
+
expect(container.querySelector('.recharts-cartesian-grid-horizontal')).toBeInTheDocument();
|
|
84
131
|
});
|
|
85
132
|
it('should render BarChartWidget with rotated XAxis labels', function () {
|
|
86
|
-
var
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
133
|
+
var container = setUp(__assign(__assign({}, defaultProps), { options: {
|
|
134
|
+
isLabelRotated: true
|
|
135
|
+
} })).container;
|
|
136
|
+
var xAxis = container.querySelector('.recharts-xAxis');
|
|
137
|
+
var xAxisLine = xAxis.querySelector('.recharts-cartesian-axis-line');
|
|
138
|
+
expect(xAxisLine).toHaveAttribute('angle', '-45');
|
|
139
|
+
expect(xAxisLine).toHaveAttribute('text-anchor', 'end');
|
|
90
140
|
});
|
|
91
141
|
it('should render YAxis for big numbers correctly', function () {
|
|
92
|
-
var
|
|
93
|
-
|
|
94
|
-
var
|
|
95
|
-
expect(
|
|
142
|
+
var container = setUp(__assign(__assign({}, defaultProps), { data: __spreadArray(__spreadArray([], defaultProps.data, true), [{ label: 'fouth', value: 100100, group: '3' }], false) })).container;
|
|
143
|
+
var yAxis = container.querySelector('.recharts-yAxis');
|
|
144
|
+
var yAxisTicks = yAxis.querySelectorAll('.recharts-cartesian-axis-tick');
|
|
145
|
+
expect(yAxisTicks).toHaveLength(8);
|
|
146
|
+
within(yAxisTicks[0]).getByText('0');
|
|
147
|
+
within(yAxisTicks[1]).getByText('15.0K');
|
|
148
|
+
within(yAxisTicks[2]).getByText('30.0K');
|
|
149
|
+
within(yAxisTicks[3]).getByText('45.0K');
|
|
150
|
+
within(yAxisTicks[4]).getByText('60.0K');
|
|
151
|
+
within(yAxisTicks[5]).getByText('75.0K');
|
|
152
|
+
within(yAxisTicks[6]).getByText('90.0K');
|
|
153
|
+
within(yAxisTicks[7]).getByText('105.0K');
|
|
96
154
|
});
|
|
97
|
-
it('should
|
|
98
|
-
var _a;
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
155
|
+
it('should call props.onItemClick on rect click', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
156
|
+
var onItemClickFn, _a, user, container, barRectangles;
|
|
157
|
+
return __generator(this, function (_b) {
|
|
158
|
+
switch (_b.label) {
|
|
159
|
+
case 0:
|
|
160
|
+
onItemClickFn = jest.fn();
|
|
161
|
+
_a = setUp(__assign(__assign({}, defaultProps), { onItemClick: onItemClickFn })), user = _a.user, container = _a.container;
|
|
162
|
+
barRectangles = container.querySelectorAll('.recharts-bar-rectangle');
|
|
163
|
+
expect(barRectangles).toHaveLength(3);
|
|
164
|
+
return [4 /*yield*/, user.click(barRectangles[0])];
|
|
165
|
+
case 1:
|
|
166
|
+
_b.sent();
|
|
167
|
+
expect(onItemClickFn).toHaveBeenLastCalledWith(defaultProps.data[0].group);
|
|
168
|
+
return [4 /*yield*/, user.click(barRectangles[1])];
|
|
169
|
+
case 2:
|
|
170
|
+
_b.sent();
|
|
171
|
+
expect(onItemClickFn).toHaveBeenLastCalledWith(defaultProps.data[1].group);
|
|
172
|
+
return [4 /*yield*/, user.click(barRectangles[2])];
|
|
173
|
+
case 3:
|
|
174
|
+
_b.sent();
|
|
175
|
+
expect(onItemClickFn).toHaveBeenLastCalledWith(defaultProps.data[2].group);
|
|
176
|
+
return [2 /*return*/];
|
|
177
|
+
}
|
|
108
178
|
});
|
|
109
|
-
});
|
|
110
|
-
it('should call props.onItemClick on rect click', function () {
|
|
111
|
-
var onItemClick = jest.fn();
|
|
112
|
-
var wrapper = mount(React.createElement(BarChart, { width: 100, height: 100, data: data, onItemClick: onItemClick }));
|
|
113
|
-
var rect = wrapper.find('.recharts-bar-rectangle').first();
|
|
114
|
-
rect.simulate('click');
|
|
115
|
-
expect(onItemClick).toBeCalledWith('1');
|
|
116
|
-
});
|
|
179
|
+
}); });
|
|
117
180
|
});
|
|
@@ -1,20 +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 } from 'enzyme';
|
|
3
13
|
import BasicAttributeSelector from './BasicAttributeSelector';
|
|
4
|
-
import {
|
|
14
|
+
import { render, screen } from '@testing-library/react';
|
|
5
15
|
describe('BasicAttributeSelector tests', function () {
|
|
6
|
-
var getAttributeTitle = function (component) { return component.find(AttributeTitle); };
|
|
7
16
|
var selectedItem = {
|
|
8
17
|
fieldName: 'selected',
|
|
9
18
|
title: 'selectedField'
|
|
10
19
|
};
|
|
11
|
-
var
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
20
|
+
var defaultProps = {
|
|
21
|
+
value: selectedItem,
|
|
22
|
+
disabled: true,
|
|
23
|
+
itemsGroups: [
|
|
24
|
+
{ attributes: [{ fieldName: 'field1', title: 'field1' }, selectedItem], title: '' },
|
|
25
|
+
{ attributes: [{ fieldName: 'field2', title: 'field2' }], title: '' }
|
|
26
|
+
],
|
|
27
|
+
onSelect: jest.fn()
|
|
28
|
+
};
|
|
29
|
+
var setUp = function (props) {
|
|
30
|
+
if (props === void 0) { props = defaultProps; }
|
|
31
|
+
return render(React.createElement(BasicAttributeSelector, __assign({}, props)));
|
|
32
|
+
};
|
|
15
33
|
it('should provide disable props to AttributeTitle', function () {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
expect(getAttributeTitle(component).prop('disabled')).toBe(true);
|
|
34
|
+
setUp();
|
|
35
|
+
expect(screen.getByText(selectedItem.title)).toHaveClass('disabled');
|
|
19
36
|
});
|
|
20
37
|
});
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { shallow } from 'enzyme';
|
|
3
2
|
import { BasicViewContent } from './BasicViewContent';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
expect(content.prop('className')).toContain('basic-view-content');
|
|
3
|
+
import { render, screen } from '@testing-library/react';
|
|
4
|
+
describe('BasicViewContent test', function () {
|
|
5
|
+
it('should render styled div with children', function () {
|
|
6
|
+
render(React.createElement(BasicViewContent, { className: 'testClassName' }, "ChildrenContent"));
|
|
7
|
+
var child = screen.getByText('ChildrenContent');
|
|
8
|
+
expect(child).toHaveClass('basic-view-content', 'testClassName');
|
|
9
|
+
});
|
|
12
10
|
});
|