@reltio/components 1.4.2050 → 1.4.2052
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/AttributeListItem/AttributeListItem.d.ts +1 -1
- package/ChartTooltip/ChartTooltip.js +3 -3
- package/ColumnsSettings/ColumnsSettings.d.ts +2 -1
- package/ColumnsSettings/ColumnsSettings.js +2 -2
- package/ColumnsSettings/ColumnsSettings.test.js +14 -0
- package/ColumnsSettings/components/ColumnListItem/ColumnListItem.d.ts +11 -26
- package/ColumnsSettings/components/ColumnListItem/ColumnListItem.js +0 -14
- package/ColumnsSettings/components/ColumnsSettingsPopup/ColumnsSettingsPopup.d.ts +2 -1
- package/ColumnsSettings/components/ColumnsSettingsPopup/ColumnsSettingsPopup.js +2 -2
- package/DropDownMenuButton/DropDownMenuButton.js +1 -1
- package/HOCs/withAsyncMount/withAsyncMount.test.js +52 -52
- package/IgnoreButton/IgnoreButton.spec.js +109 -20
- package/Image/Image.d.ts +1 -1
- package/Image/Image.js +8 -8
- package/Image/Image.test.js +46 -51
- package/ImageActionsOverlay/ImageActionsOverlay.js +2 -1
- package/ImageActionsOverlay/ImageActionsOverlay.test.js +207 -125
- package/ImageActionsOverlay/components/CheckedIcon/CheckedIcon.js +1 -1
- package/ImageAttributesGallery/ImageAttributesGallery.test.js +525 -281
- package/ImageAttributesLine/ImageAttributesLine.js +1 -1
- package/ImageAttributesLine/ImageAttributesLine.test.js +187 -193
- package/ImageAttributesLine/imageAttributeValues.test-data.d.ts +10 -0
- package/ImageAttributesLine/imageAttributeValues.test-data.js +22 -0
- package/ImageAttributesLineEditor/ImageAttributesLineEditor.test.js +315 -298
- package/ImageDetailsView/ImageDetailsView.test.js +529 -55
- package/ImageDetailsView/attributes.test-data.d.ts +4 -1
- package/ImageDetailsView/attributes.test-data.js +98 -1
- package/ImageDetailsView/components/ImageDetailsViewCarousel/ImageDetailsViewCarousel.js +2 -2
- package/ImageDetailsView/components/MetaInfoItem/MetaInfoItem.js +1 -1
- package/ImageDetailsView/components/MetaInfoList/MetaInfoList.js +1 -1
- package/ImageDetailsView/components/Thumbnails/Thumbnails.js +1 -1
- package/ImageDetailsView/helpers.test.js +4 -4
- package/ImageGalleryDialog/ImageGalleryDialog.test.js +89 -46
- package/ImportButton/ImportButton.test.js +94 -24
- package/InlineAttributesList/InlineAttributesList.test.js +22 -62
- package/InlineAttributesList/attributes.test-data.d.ts +4 -2
- package/InlineAttributesList/attributes.test-data.js +40 -1
- package/InlineAttributesPager/InlineAttributesPager.d.ts +1 -2
- package/InlineAttributesPager/InlineAttributesPager.js +1 -4
- package/InlineAttributesPager/InlineAttributesPager.test.js +393 -183
- package/InlineComplexAttribute/InlineComplexAttribute.js +1 -1
- package/InlineComplexAttribute/InlineComplexAttribute.test.js +396 -182
- package/InlineImageAttribute/InlineImageAttribute.test.js +103 -55
- package/InlineNestedAttribute/InlineNestedAttribute.test.js +105 -43
- package/InlineReferenceAttribute/InlineReferenceAttribute.test.js +165 -107
- package/InlineSimpleAttribute/InlineSimpleAttribute.spec.js +352 -346
- package/InlineSimpleAttributeEditor/InlineSimpleAttributeEditor.test.js +285 -194
- package/InternalLink/InternalLink.test.js +41 -11
- package/LookupEditor/LookupEditor.test.js +180 -44
- package/LookupEditor/components/GroupedDropDownEditor/helpers.test.js +1 -1
- package/MapChart/MapChart.js +3 -8
- package/MapChart/MapChart.test.js +152 -188
- package/MapChart/components/Legend/Legend.js +3 -3
- package/MaskingSwitcher/MaskingSwitcher.js +1 -1
- package/MatchRulesBadge/MatchRulesBadge.test.js +93 -24
- package/SelectEditor/SelectEditor.d.ts +4 -10
- package/SelectEditor/SelectEditor.js +0 -4
- package/SelectEditor/SelectEditor.test.js +79 -9
- package/SelectionPopup/SelectionPopup.d.ts +2 -1
- package/SelectionPopup/SelectionPopup.js +3 -3
- package/SelectionPopup/SelectionPopup.spec.js +90 -30
- package/cjs/AttributeListItem/AttributeListItem.d.ts +1 -1
- package/cjs/ChartTooltip/ChartTooltip.js +3 -3
- package/cjs/ColumnsSettings/ColumnsSettings.d.ts +2 -1
- package/cjs/ColumnsSettings/ColumnsSettings.js +2 -2
- package/cjs/ColumnsSettings/ColumnsSettings.test.js +14 -0
- package/cjs/ColumnsSettings/components/ColumnListItem/ColumnListItem.d.ts +11 -26
- package/cjs/ColumnsSettings/components/ColumnListItem/ColumnListItem.js +0 -14
- package/cjs/ColumnsSettings/components/ColumnsSettingsPopup/ColumnsSettingsPopup.d.ts +2 -1
- package/cjs/ColumnsSettings/components/ColumnsSettingsPopup/ColumnsSettingsPopup.js +2 -2
- package/cjs/DropDownMenuButton/DropDownMenuButton.js +1 -1
- package/cjs/HOCs/withAsyncMount/withAsyncMount.test.js +56 -56
- package/cjs/IgnoreButton/IgnoreButton.spec.js +109 -20
- package/cjs/Image/Image.d.ts +1 -1
- package/cjs/Image/Image.js +8 -8
- package/cjs/Image/Image.test.js +46 -51
- package/cjs/ImageActionsOverlay/ImageActionsOverlay.js +2 -1
- package/cjs/ImageActionsOverlay/ImageActionsOverlay.test.js +207 -125
- package/cjs/ImageActionsOverlay/components/CheckedIcon/CheckedIcon.js +1 -1
- package/cjs/ImageAttributesGallery/ImageAttributesGallery.test.js +525 -281
- package/cjs/ImageAttributesLine/ImageAttributesLine.js +1 -1
- package/cjs/ImageAttributesLine/ImageAttributesLine.test.js +195 -224
- package/cjs/ImageAttributesLine/imageAttributeValues.test-data.d.ts +10 -0
- package/cjs/ImageAttributesLine/imageAttributeValues.test-data.js +23 -1
- package/cjs/ImageAttributesLineEditor/ImageAttributesLineEditor.test.js +316 -299
- package/cjs/ImageDetailsView/ImageDetailsView.test.js +529 -55
- package/cjs/ImageDetailsView/attributes.test-data.d.ts +4 -1
- package/cjs/ImageDetailsView/attributes.test-data.js +99 -2
- package/cjs/ImageDetailsView/components/ImageDetailsViewCarousel/ImageDetailsViewCarousel.js +2 -2
- package/cjs/ImageDetailsView/components/MetaInfoItem/MetaInfoItem.js +1 -1
- package/cjs/ImageDetailsView/components/MetaInfoList/MetaInfoList.js +1 -1
- package/cjs/ImageDetailsView/components/Thumbnails/Thumbnails.js +1 -1
- package/cjs/ImageDetailsView/helpers.test.js +3 -3
- package/cjs/ImageGalleryDialog/ImageGalleryDialog.test.js +89 -46
- package/cjs/ImportButton/ImportButton.test.js +94 -24
- package/cjs/InlineAttributesList/InlineAttributesList.test.js +22 -62
- package/cjs/InlineAttributesList/attributes.test-data.d.ts +4 -2
- package/cjs/InlineAttributesList/attributes.test-data.js +41 -2
- package/cjs/InlineAttributesPager/InlineAttributesPager.d.ts +1 -2
- package/cjs/InlineAttributesPager/InlineAttributesPager.js +1 -4
- package/cjs/InlineAttributesPager/InlineAttributesPager.test.js +393 -183
- package/cjs/InlineComplexAttribute/InlineComplexAttribute.js +1 -1
- package/cjs/InlineComplexAttribute/InlineComplexAttribute.test.js +395 -204
- package/cjs/InlineImageAttribute/InlineImageAttribute.test.js +103 -55
- package/cjs/InlineNestedAttribute/InlineNestedAttribute.test.js +105 -43
- package/cjs/InlineReferenceAttribute/InlineReferenceAttribute.test.js +164 -106
- package/cjs/InlineSimpleAttribute/InlineSimpleAttribute.spec.js +351 -345
- package/cjs/InlineSimpleAttributeEditor/InlineSimpleAttributeEditor.test.js +307 -193
- package/cjs/InternalLink/InternalLink.test.js +40 -10
- package/cjs/LookupEditor/LookupEditor.test.js +178 -65
- package/cjs/LookupEditor/components/GroupedDropDownEditor/helpers.test.js +1 -1
- package/cjs/MapChart/MapChart.js +3 -8
- package/cjs/MapChart/MapChart.test.js +152 -188
- package/cjs/MapChart/components/Legend/Legend.js +3 -3
- package/cjs/MaskingSwitcher/MaskingSwitcher.js +1 -1
- package/cjs/MatchRulesBadge/MatchRulesBadge.test.js +93 -24
- package/cjs/SelectEditor/SelectEditor.d.ts +4 -10
- package/cjs/SelectEditor/SelectEditor.js +0 -4
- package/cjs/SelectEditor/SelectEditor.test.js +79 -9
- package/cjs/SelectionPopup/SelectionPopup.d.ts +2 -1
- package/cjs/SelectionPopup/SelectionPopup.js +3 -3
- package/cjs/SelectionPopup/SelectionPopup.spec.js +90 -30
- package/cjs/hooks/useAsyncMount/useAsyncMount.d.ts +1 -1
- package/cjs/hooks/useAsyncMount/useAsyncMount.js +1 -1
- package/hooks/useAsyncMount/useAsyncMount.d.ts +1 -1
- package/hooks/useAsyncMount/useAsyncMount.js +1 -1
- package/package.json +1 -1
- package/HOCs/withTableContext/withTableContext.test.d.ts +0 -1
- package/HOCs/withTableContext/withTableContext.test.js +0 -41
- package/ImageAttributesGallery/components/GalleryView/GalleryView.test.d.ts +0 -1
- package/ImageAttributesGallery/components/GalleryView/GalleryView.test.js +0 -98
- package/ImageDetailsView/components/ImageDetailsViewCarousel/ImageDetailsViewCarousel.test.d.ts +0 -1
- package/ImageDetailsView/components/ImageDetailsViewCarousel/ImageDetailsViewCarousel.test.js +0 -99
- package/ImageDetailsView/components/ImageDetailsViewSidebar/ImageDetailsViewSidebar.test.d.ts +0 -1
- package/ImageDetailsView/components/ImageDetailsViewSidebar/ImageDetailsViewSidebar.test.js +0 -65
- package/ImageDetailsView/components/MetaInfo/MetaInfo.test.d.ts +0 -1
- package/ImageDetailsView/components/MetaInfo/MetaInfo.test.js +0 -306
- package/ImageDetailsView/components/MetaInfoForm/MetaInfoForm.test.d.ts +0 -1
- package/ImageDetailsView/components/MetaInfoForm/MetaInfoForm.test.js +0 -134
- package/ImageDetailsView/components/MetaInfoHeader/MetaInfoHeader.test.d.ts +0 -1
- package/ImageDetailsView/components/MetaInfoHeader/MetaInfoHeader.test.js +0 -99
- package/ImageDetailsView/components/MetaInfoItem/MetaInfoItem.test.d.ts +0 -1
- package/ImageDetailsView/components/MetaInfoItem/MetaInfoItem.test.js +0 -36
- package/ImageDetailsView/components/MetaInfoList/MetaInfoList.test.d.ts +0 -1
- package/ImageDetailsView/components/MetaInfoList/MetaInfoList.test.js +0 -161
- package/ImageDetailsView/components/Thumbnails/Thumbnails.test.d.ts +0 -1
- package/ImageDetailsView/components/Thumbnails/Thumbnails.test.js +0 -76
- package/InlineAttributesPager/components/InlineImageAttributesBlock/InlineImageAttributesBlock.test.d.ts +0 -1
- package/InlineAttributesPager/components/InlineImageAttributesBlock/InlineImageAttributesBlock.test.js +0 -104
- package/InlineAttributesPager/components/InlineNestedAttributesBlock/InlineNestedAttributesBlock.test.d.ts +0 -1
- package/InlineAttributesPager/components/InlineNestedAttributesBlock/InlineNestedAttributesBlock.test.js +0 -114
- package/InlineAttributesPager/components/InlineReferenceAttributesBlock/InlineReferenceAttributesBlock.test.d.ts +0 -1
- package/InlineAttributesPager/components/InlineReferenceAttributesBlock/InlineReferenceAttributesBlock.test.js +0 -177
- package/InlineSimpleAttribute/components/CrosswalkMenuItem/CrosswalkMenuItem.spec.d.ts +0 -1
- package/InlineSimpleAttribute/components/CrosswalkMenuItem/CrosswalkMenuItem.spec.js +0 -52
- package/LookupEditor/components/GroupedDropDownEditor/GroupedDropDownEditor.test.d.ts +0 -1
- package/LookupEditor/components/GroupedDropDownEditor/GroupedDropDownEditor.test.js +0 -37
- package/cjs/HOCs/withTableContext/withTableContext.test.d.ts +0 -1
- package/cjs/HOCs/withTableContext/withTableContext.test.js +0 -46
- package/cjs/ImageAttributesGallery/components/GalleryView/GalleryView.test.d.ts +0 -1
- package/cjs/ImageAttributesGallery/components/GalleryView/GalleryView.test.js +0 -103
- package/cjs/ImageDetailsView/components/ImageDetailsViewCarousel/ImageDetailsViewCarousel.test.d.ts +0 -1
- package/cjs/ImageDetailsView/components/ImageDetailsViewCarousel/ImageDetailsViewCarousel.test.js +0 -104
- package/cjs/ImageDetailsView/components/ImageDetailsViewSidebar/ImageDetailsViewSidebar.test.d.ts +0 -1
- package/cjs/ImageDetailsView/components/ImageDetailsViewSidebar/ImageDetailsViewSidebar.test.js +0 -70
- package/cjs/ImageDetailsView/components/MetaInfo/MetaInfo.test.d.ts +0 -1
- package/cjs/ImageDetailsView/components/MetaInfo/MetaInfo.test.js +0 -311
- package/cjs/ImageDetailsView/components/MetaInfoForm/MetaInfoForm.test.d.ts +0 -1
- package/cjs/ImageDetailsView/components/MetaInfoForm/MetaInfoForm.test.js +0 -139
- package/cjs/ImageDetailsView/components/MetaInfoHeader/MetaInfoHeader.test.d.ts +0 -1
- package/cjs/ImageDetailsView/components/MetaInfoHeader/MetaInfoHeader.test.js +0 -104
- package/cjs/ImageDetailsView/components/MetaInfoItem/MetaInfoItem.test.d.ts +0 -1
- package/cjs/ImageDetailsView/components/MetaInfoItem/MetaInfoItem.test.js +0 -41
- package/cjs/ImageDetailsView/components/MetaInfoList/MetaInfoList.test.d.ts +0 -1
- package/cjs/ImageDetailsView/components/MetaInfoList/MetaInfoList.test.js +0 -166
- package/cjs/ImageDetailsView/components/Thumbnails/Thumbnails.test.d.ts +0 -1
- package/cjs/ImageDetailsView/components/Thumbnails/Thumbnails.test.js +0 -81
- package/cjs/InlineAttributesPager/components/InlineImageAttributesBlock/InlineImageAttributesBlock.test.d.ts +0 -1
- package/cjs/InlineAttributesPager/components/InlineImageAttributesBlock/InlineImageAttributesBlock.test.js +0 -109
- package/cjs/InlineAttributesPager/components/InlineNestedAttributesBlock/InlineNestedAttributesBlock.test.d.ts +0 -1
- package/cjs/InlineAttributesPager/components/InlineNestedAttributesBlock/InlineNestedAttributesBlock.test.js +0 -119
- package/cjs/InlineAttributesPager/components/InlineReferenceAttributesBlock/InlineReferenceAttributesBlock.test.d.ts +0 -1
- package/cjs/InlineAttributesPager/components/InlineReferenceAttributesBlock/InlineReferenceAttributesBlock.test.js +0 -182
- package/cjs/InlineSimpleAttribute/components/CrosswalkMenuItem/CrosswalkMenuItem.spec.d.ts +0 -1
- package/cjs/InlineSimpleAttribute/components/CrosswalkMenuItem/CrosswalkMenuItem.spec.js +0 -57
- package/cjs/LookupEditor/components/GroupedDropDownEditor/GroupedDropDownEditor.test.d.ts +0 -1
- package/cjs/LookupEditor/components/GroupedDropDownEditor/GroupedDropDownEditor.test.js +0 -42
|
@@ -1,65 +0,0 @@
|
|
|
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
|
-
import React from 'react';
|
|
13
|
-
import { mount } from 'enzyme';
|
|
14
|
-
import { Mode } from '@reltio/mdm-sdk';
|
|
15
|
-
import { MetaInfo } from '../MetaInfo';
|
|
16
|
-
import { MdmModuleProvider } from '../../../contexts/MdmModuleContext';
|
|
17
|
-
import { ImageDetailsViewSidebar } from './ImageDetailsViewSidebar';
|
|
18
|
-
var mdmValues = {
|
|
19
|
-
mode: Mode.Viewing,
|
|
20
|
-
imageAttributesFieldsOrder: {}
|
|
21
|
-
};
|
|
22
|
-
var setUp = function (props) {
|
|
23
|
-
return mount(React.createElement(MdmModuleProvider, { values: mdmValues },
|
|
24
|
-
React.createElement(ImageDetailsViewSidebar, __assign({}, props))));
|
|
25
|
-
};
|
|
26
|
-
describe('DetailsViewSidebar tests', function () {
|
|
27
|
-
var attributeType = {
|
|
28
|
-
attributes: [],
|
|
29
|
-
name: 'ImageGallery',
|
|
30
|
-
type: 'Image',
|
|
31
|
-
uri: 'configuration/entityTypes/Employee/attributes/ImageGallery'
|
|
32
|
-
};
|
|
33
|
-
it('should render MetaInfo and provide correct props', function () {
|
|
34
|
-
var attributeValue = {
|
|
35
|
-
uri: '1',
|
|
36
|
-
value: {
|
|
37
|
-
CdnUrl: [{ value: 'https://google.com', uri: '1' }],
|
|
38
|
-
CdnUrlPreview: [{ value: 'https://twitter.com', uri: '2' }],
|
|
39
|
-
CdnUrlThumbnail: [{ value: 'https://facebook.com', uri: '3' }],
|
|
40
|
-
CreationTimestamp: [{ value: '2021-06-09T13:13:16.563Z', uri: '4' }],
|
|
41
|
-
Height: [{ value: '500', uri: '5' }],
|
|
42
|
-
MimeType: [{ value: 'image/png', uri: '6' }],
|
|
43
|
-
Size: [{ value: '5000', uri: '7' }],
|
|
44
|
-
Url: [{ value: 'https://vk.com', uri: '8' }],
|
|
45
|
-
UrlPreview: [{ value: 'https://github.com', uri: '9' }],
|
|
46
|
-
UrlThumbnail: [{ value: 'https://bitbucket.com', uri: '10' }],
|
|
47
|
-
Width: [{ value: '400', uri: '11' }]
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
var component = setUp({ attributeValue: attributeValue, handleSetAsDefault: jest.fn(), attributeType: attributeType });
|
|
51
|
-
var metaInfo = component.find(MetaInfo);
|
|
52
|
-
expect(metaInfo.length).toBe(1);
|
|
53
|
-
expect(metaInfo.prop('attributeValue')).toStrictEqual(attributeValue);
|
|
54
|
-
});
|
|
55
|
-
it('should render MetaInfo without currentImage.value', function () {
|
|
56
|
-
var attributeValue = {
|
|
57
|
-
uri: '1',
|
|
58
|
-
value: {}
|
|
59
|
-
};
|
|
60
|
-
var component = setUp({ attributeValue: attributeValue, handleSetAsDefault: jest.fn(), attributeType: attributeType });
|
|
61
|
-
var metaInfo = component.find(MetaInfo);
|
|
62
|
-
expect(metaInfo.length).toBe(1);
|
|
63
|
-
expect(metaInfo.prop('attributeValue')).toStrictEqual(attributeValue);
|
|
64
|
-
});
|
|
65
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,306 +0,0 @@
|
|
|
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
|
-
import React from 'react';
|
|
13
|
-
import { toPairs, fromPairs, clone } from 'ramda';
|
|
14
|
-
import { act } from 'react-dom/test-utils';
|
|
15
|
-
import { mount } from 'enzyme';
|
|
16
|
-
import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider';
|
|
17
|
-
import { AdapterMoment } from '@mui/x-date-pickers/AdapterMoment';
|
|
18
|
-
import { Mode } from '@reltio/mdm-sdk';
|
|
19
|
-
import { ThemeProvider } from '@mui/material/styles';
|
|
20
|
-
import { MetaInfoHeader } from '../MetaInfoHeader';
|
|
21
|
-
import { MetaInfoList } from '../MetaInfoList';
|
|
22
|
-
import { MetaInfoForm } from '../MetaInfoForm';
|
|
23
|
-
import { attributeType, attributeValue } from '../../attributes.test-data';
|
|
24
|
-
import { MdmModuleProvider } from '../../../contexts/MdmModuleContext';
|
|
25
|
-
import { MetaInfo } from './MetaInfo';
|
|
26
|
-
jest.mock('../MetaInfoForm', function () { return ({ MetaInfoForm: function () { return null; } }); });
|
|
27
|
-
jest.mock('../MetaInfoHeader', function () { return ({ MetaInfoHeader: function () { return null; } }); });
|
|
28
|
-
jest.mock('../MetaInfoList', function () { return ({ MetaInfoList: function () { return null; } }); });
|
|
29
|
-
var modifyAttribute = jest.fn();
|
|
30
|
-
var setUp = function (mode) {
|
|
31
|
-
if (mode === void 0) { mode = Mode.Viewing; }
|
|
32
|
-
var props = { attributeValue: attributeValue, attributeType: attributeType, imageAttributeFieldsOrder: {} };
|
|
33
|
-
var Component = function (props) { return (React.createElement(LocalizationProvider, { dateAdapter: AdapterMoment },
|
|
34
|
-
React.createElement(MdmModuleProvider, { values: { mode: mode }, actions: { modifyAttribute: modifyAttribute } },
|
|
35
|
-
React.createElement(MetaInfo, __assign({}, props))))); };
|
|
36
|
-
return mount(React.createElement(Component, __assign({}, props)));
|
|
37
|
-
};
|
|
38
|
-
describe('MetaInfo tests', function () {
|
|
39
|
-
describe('render tests', function () {
|
|
40
|
-
it('should render ThemeProvider correctly', function () {
|
|
41
|
-
var component = setUp(Mode.Viewing);
|
|
42
|
-
expect(component.find(ThemeProvider)).toHaveLength(1);
|
|
43
|
-
});
|
|
44
|
-
it('should render MetaInfoHeader correctly', function () {
|
|
45
|
-
var component = setUp(Mode.Viewing);
|
|
46
|
-
expect(component.find(MetaInfoHeader).props()).toMatchObject({
|
|
47
|
-
attributeType: attributeType,
|
|
48
|
-
uri: attributeValue.uri
|
|
49
|
-
});
|
|
50
|
-
});
|
|
51
|
-
it('should pass correctly onAddAttributes prop to MetaInfoHeader if mode is "Viewing"', function () {
|
|
52
|
-
var component = setUp(Mode.Viewing);
|
|
53
|
-
expect(component.find(MetaInfoHeader).prop('onAddAttributes')).toBeUndefined();
|
|
54
|
-
});
|
|
55
|
-
it('should pass correctly onAddAttributes prop to MetaInfoHeader if mode is "Editing"', function () {
|
|
56
|
-
var component = setUp(Mode.Editing);
|
|
57
|
-
expect(component.find(MetaInfoHeader).prop('onAddAttributes')).toBeDefined();
|
|
58
|
-
});
|
|
59
|
-
it('should pass correctly onAddAttributes prop to MetaInfoHeader if mode is "Suggesting"', function () {
|
|
60
|
-
var component = setUp(Mode.Suggesting);
|
|
61
|
-
expect(component.find(MetaInfoHeader).prop('onAddAttributes')).toBeDefined();
|
|
62
|
-
});
|
|
63
|
-
it('should render MetaInfoList correctly', function () {
|
|
64
|
-
var component = setUp(Mode.Viewing);
|
|
65
|
-
expect(component.find(MetaInfoList).props()).toMatchObject({
|
|
66
|
-
attributeType: attributeType,
|
|
67
|
-
attributeValue: attributeValue,
|
|
68
|
-
imageAttributeFieldsOrder: {}
|
|
69
|
-
});
|
|
70
|
-
});
|
|
71
|
-
var checkMetaInfoForm = function (component, mode) {
|
|
72
|
-
expect(component.find(MetaInfoForm).props()).toMatchObject({
|
|
73
|
-
mode: mode,
|
|
74
|
-
imageAttributeFieldsOrder: {},
|
|
75
|
-
attributeType: attributeType,
|
|
76
|
-
attributeValue: attributeValue,
|
|
77
|
-
hasChanges: false
|
|
78
|
-
});
|
|
79
|
-
expect(component.find(MetaInfoForm).prop('onDeleteAttribute')).toBeDefined();
|
|
80
|
-
expect(component.find(MetaInfoForm).prop('onChangeAttribute')).toBeDefined();
|
|
81
|
-
expect(component.find(MetaInfoForm).prop('onAddAttributes')).toBeDefined();
|
|
82
|
-
expect(component.find(MetaInfoForm).prop('onCancel')).toBeDefined();
|
|
83
|
-
expect(component.find(MetaInfoForm).prop('onApply')).toBeDefined();
|
|
84
|
-
};
|
|
85
|
-
it('should render MetaInfoForm correctly if mode is "Editing"', function () {
|
|
86
|
-
var component = setUp(Mode.Editing);
|
|
87
|
-
checkMetaInfoForm(component, Mode.Editing);
|
|
88
|
-
});
|
|
89
|
-
it('should render MetaInfoForm correctly if mode is "Suggesting"', function () {
|
|
90
|
-
var component = setUp(Mode.Suggesting);
|
|
91
|
-
checkMetaInfoForm(component, Mode.Suggesting);
|
|
92
|
-
});
|
|
93
|
-
it('should not render MetaInfoForm if mode is "Viewing"', function () {
|
|
94
|
-
var component = setUp(Mode.Viewing);
|
|
95
|
-
expect(component.find(MetaInfoForm)).toHaveLength(0);
|
|
96
|
-
});
|
|
97
|
-
});
|
|
98
|
-
describe('useEditMetaInfo', function () {
|
|
99
|
-
beforeEach(function () {
|
|
100
|
-
jest.restoreAllMocks();
|
|
101
|
-
});
|
|
102
|
-
it('should return attributeValue correctly', function () {
|
|
103
|
-
var component = setUp(Mode.Editing);
|
|
104
|
-
expect(component.find(MetaInfoForm).prop('attributeValue')).toEqual(attributeValue);
|
|
105
|
-
});
|
|
106
|
-
it('addAttributes should work correctly for existing attributes', function () {
|
|
107
|
-
var component = setUp(Mode.Editing);
|
|
108
|
-
var onAddAttributes = component.find(MetaInfoForm).prop('onAddAttributes');
|
|
109
|
-
var attributes = [
|
|
110
|
-
{
|
|
111
|
-
parentUri: 'entities/15RRKaId/attributes/ImageGallery/3aL9d7zDM',
|
|
112
|
-
index: undefined,
|
|
113
|
-
attributeType: {
|
|
114
|
-
label: 'String',
|
|
115
|
-
name: 'String',
|
|
116
|
-
type: 'String',
|
|
117
|
-
system: false,
|
|
118
|
-
uri: 'configuration/entityTypes/HCP/attributes/ImageGallery/attributes/String'
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
];
|
|
122
|
-
act(function () {
|
|
123
|
-
onAddAttributes(attributes);
|
|
124
|
-
});
|
|
125
|
-
component.update();
|
|
126
|
-
var updatedAttributeValue = component.find(MetaInfoForm).prop('attributeValue');
|
|
127
|
-
var string = updatedAttributeValue.value.String;
|
|
128
|
-
expect(string[1]).toEqual(attributeValue.value.String[0]);
|
|
129
|
-
expect(string[0].value).toBe('');
|
|
130
|
-
expect(string[0].type).toBe('configuration/entityTypes/HCP/attributes/ImageGallery/attributes/String');
|
|
131
|
-
expect(string[0].uri.startsWith('entities/15RRKaId/attributes/ImageGallery/3aL9d7zDM/String')).toBe(true);
|
|
132
|
-
});
|
|
133
|
-
it('addAttributes should work correctly for not existing attributes', function () {
|
|
134
|
-
var component = setUp(Mode.Editing);
|
|
135
|
-
var onAddAttributes = component.find(MetaInfoHeader).prop('onAddAttributes');
|
|
136
|
-
var attributes = [
|
|
137
|
-
{
|
|
138
|
-
attributeType: {
|
|
139
|
-
label: 'Float',
|
|
140
|
-
name: 'Float',
|
|
141
|
-
type: 'Float',
|
|
142
|
-
system: false,
|
|
143
|
-
uri: 'configuration/entityTypes/HCP/attributes/ImageGallery/attributes/Float'
|
|
144
|
-
},
|
|
145
|
-
parentUri: 'entities/15RRKaId/attributes/ImageGallery/3aL9d7zDM'
|
|
146
|
-
},
|
|
147
|
-
{
|
|
148
|
-
attributeType: {
|
|
149
|
-
label: 'Long',
|
|
150
|
-
name: 'Long',
|
|
151
|
-
type: 'Long',
|
|
152
|
-
system: false,
|
|
153
|
-
uri: 'configuration/entityTypes/HCP/attributes/ImageGallery/attributes/Long'
|
|
154
|
-
},
|
|
155
|
-
parentUri: 'entities/15RRKaId/attributes/ImageGallery/3aL9d7zDM'
|
|
156
|
-
}
|
|
157
|
-
];
|
|
158
|
-
act(function () {
|
|
159
|
-
if (onAddAttributes) {
|
|
160
|
-
onAddAttributes(attributes);
|
|
161
|
-
}
|
|
162
|
-
});
|
|
163
|
-
component.update();
|
|
164
|
-
var updatedAttributeValue = component.find(MetaInfoForm).prop('attributeValue');
|
|
165
|
-
var float = updatedAttributeValue.value.Float;
|
|
166
|
-
expect(float[0].value).toBe('');
|
|
167
|
-
expect(float[0].type).toBe('configuration/entityTypes/HCP/attributes/ImageGallery/attributes/Float');
|
|
168
|
-
expect(float[0].uri.startsWith('entities/15RRKaId/attributes/ImageGallery/3aL9d7zDM/Float')).toBe(true);
|
|
169
|
-
var long = updatedAttributeValue.value.Long;
|
|
170
|
-
expect(long[0].value).toBe('');
|
|
171
|
-
expect(long[0].type).toBe('configuration/entityTypes/HCP/attributes/ImageGallery/attributes/Long');
|
|
172
|
-
expect(long[0].uri.startsWith('entities/15RRKaId/attributes/ImageGallery/3aL9d7zDM/Long')).toBe(true);
|
|
173
|
-
});
|
|
174
|
-
it('changeAttribute handler should work correctly', function () {
|
|
175
|
-
var component = setUp(Mode.Editing);
|
|
176
|
-
var onChangeAttribute = component.find(MetaInfoForm).prop('onChangeAttribute');
|
|
177
|
-
var changes = {
|
|
178
|
-
value: 'hello',
|
|
179
|
-
attributeType: {
|
|
180
|
-
label: 'String',
|
|
181
|
-
name: 'String',
|
|
182
|
-
type: 'String',
|
|
183
|
-
system: false,
|
|
184
|
-
uri: 'configuration/entityTypes/HCP/attributes/ImageGallery/attributes/String'
|
|
185
|
-
},
|
|
186
|
-
uri: 'entities/15RRKaId/attributes/ImageGallery/3aL9d7zDM/String/3aL9d8oMS'
|
|
187
|
-
};
|
|
188
|
-
act(function () {
|
|
189
|
-
onChangeAttribute(changes);
|
|
190
|
-
});
|
|
191
|
-
component.update();
|
|
192
|
-
var expectedResult = __assign(__assign({}, attributeValue), { value: __assign(__assign({}, attributeValue.value), { String: [
|
|
193
|
-
__assign(__assign({}, attributeValue.value.String[0]), { value: 'hello' }),
|
|
194
|
-
attributeValue.value.String[1]
|
|
195
|
-
] }) });
|
|
196
|
-
expect(component.find(MetaInfoForm).prop('attributeValue')).toEqual(expectedResult);
|
|
197
|
-
});
|
|
198
|
-
it('deleteAttribute handler should work correctly', function () {
|
|
199
|
-
var component = setUp(Mode.Editing);
|
|
200
|
-
var onDeleteAttribute = component.find(MetaInfoForm).prop('onDeleteAttribute');
|
|
201
|
-
var changes = {
|
|
202
|
-
attributeType: {
|
|
203
|
-
label: 'Date',
|
|
204
|
-
name: 'Date',
|
|
205
|
-
type: 'Date',
|
|
206
|
-
system: false,
|
|
207
|
-
uri: 'configuration/entityTypes/HCP/attributes/ImageGallery/attributes/Date'
|
|
208
|
-
},
|
|
209
|
-
uri: 'entities/15RRKaId/attributes/ImageGallery/3aL9d7zDM/Date/uri$$1626678310141'
|
|
210
|
-
};
|
|
211
|
-
act(function () {
|
|
212
|
-
onDeleteAttribute(changes);
|
|
213
|
-
});
|
|
214
|
-
component.update();
|
|
215
|
-
var expectedResult = __assign(__assign({}, attributeValue), { value: __assign({}, fromPairs(toPairs(attributeValue.value).filter(function (_a) {
|
|
216
|
-
var key = _a[0];
|
|
217
|
-
return key !== 'Date';
|
|
218
|
-
}))) });
|
|
219
|
-
expect(component.find(MetaInfoForm).prop('attributeValue')).toEqual(expectedResult);
|
|
220
|
-
});
|
|
221
|
-
it('clearLocalChanges should work correctly', function () {
|
|
222
|
-
var component = setUp(Mode.Editing);
|
|
223
|
-
var onCancel = component.find(MetaInfoForm).prop('onCancel');
|
|
224
|
-
var onChangeAttribute = component.find(MetaInfoForm).prop('onChangeAttribute');
|
|
225
|
-
var changes = {
|
|
226
|
-
value: 'hello',
|
|
227
|
-
attributeType: {
|
|
228
|
-
label: 'String',
|
|
229
|
-
name: 'String',
|
|
230
|
-
type: 'String',
|
|
231
|
-
system: false,
|
|
232
|
-
uri: 'configuration/entityTypes/HCP/attributes/ImageGallery/attributes/String'
|
|
233
|
-
},
|
|
234
|
-
uri: 'entities/15RRKaId/attributes/ImageGallery/3aL9d7zDM/String/3aL9d8oMS'
|
|
235
|
-
};
|
|
236
|
-
act(function () {
|
|
237
|
-
onChangeAttribute(changes);
|
|
238
|
-
});
|
|
239
|
-
component.update();
|
|
240
|
-
expect(component.find(MetaInfoForm).prop('attributeValue')).not.toEqual(attributeValue);
|
|
241
|
-
act(function () {
|
|
242
|
-
onCancel();
|
|
243
|
-
});
|
|
244
|
-
component.update();
|
|
245
|
-
expect(component.find(MetaInfoForm).prop('attributeValue')).toEqual(attributeValue);
|
|
246
|
-
});
|
|
247
|
-
it('applyLocalChanges should work correctly', function () {
|
|
248
|
-
var component = setUp(Mode.Editing);
|
|
249
|
-
var onApply = component.find(MetaInfoForm).prop('onApply');
|
|
250
|
-
act(function () {
|
|
251
|
-
onApply();
|
|
252
|
-
});
|
|
253
|
-
component.update();
|
|
254
|
-
expect(modifyAttribute).toHaveBeenCalledWith({
|
|
255
|
-
value: attributeValue,
|
|
256
|
-
attributeType: attributeType,
|
|
257
|
-
uri: 'entities/15RRKaId/attributes/ImageGallery/3aL9d7zDM'
|
|
258
|
-
});
|
|
259
|
-
});
|
|
260
|
-
it('should return hasChanges correctly', function () {
|
|
261
|
-
var component = setUp(Mode.Editing);
|
|
262
|
-
expect(component.find(MetaInfoForm).prop('hasChanges')).toBe(false);
|
|
263
|
-
var onCancel = component.find(MetaInfoForm).prop('onCancel');
|
|
264
|
-
var onChangeAttribute = component.find(MetaInfoForm).prop('onChangeAttribute');
|
|
265
|
-
var changes = {
|
|
266
|
-
value: 'hello',
|
|
267
|
-
attributeType: {
|
|
268
|
-
label: 'String',
|
|
269
|
-
name: 'String',
|
|
270
|
-
type: 'String',
|
|
271
|
-
system: false,
|
|
272
|
-
uri: 'configuration/entityTypes/HCP/attributes/ImageGallery/attributes/String'
|
|
273
|
-
},
|
|
274
|
-
uri: 'entities/15RRKaId/attributes/ImageGallery/3aL9d7zDM/String/3aL9d8oMS'
|
|
275
|
-
};
|
|
276
|
-
act(function () {
|
|
277
|
-
onChangeAttribute(changes);
|
|
278
|
-
});
|
|
279
|
-
component.update();
|
|
280
|
-
expect(component.find(MetaInfoForm).prop('hasChanges')).toBe(true);
|
|
281
|
-
act(function () {
|
|
282
|
-
onCancel();
|
|
283
|
-
});
|
|
284
|
-
component.update();
|
|
285
|
-
expect(component.find(MetaInfoForm).prop('hasChanges')).toBe(false);
|
|
286
|
-
});
|
|
287
|
-
it('should reflect value update', function () {
|
|
288
|
-
var component = setUp(Mode.Editing);
|
|
289
|
-
expect(component.find(MetaInfoForm).prop('attributeValue')).toEqual(attributeValue);
|
|
290
|
-
var newValue = clone(attributeValue);
|
|
291
|
-
newValue.value.Size = [
|
|
292
|
-
{
|
|
293
|
-
type: 'configuration/entityTypes/HCP/attributes/ImageGallery/attributes/Size',
|
|
294
|
-
ov: true,
|
|
295
|
-
value: '4444',
|
|
296
|
-
uri: 'entities/15RRKaId/attributes/ImageGallery/3aL9d7zDM/Size/3aL9d8bZg'
|
|
297
|
-
}
|
|
298
|
-
];
|
|
299
|
-
act(function () {
|
|
300
|
-
component.setProps({ attributeValue: newValue });
|
|
301
|
-
});
|
|
302
|
-
component.update();
|
|
303
|
-
expect(component.find(MetaInfoForm).prop('attributeValue')).toEqual(newValue);
|
|
304
|
-
});
|
|
305
|
-
});
|
|
306
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,134 +0,0 @@
|
|
|
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
|
-
import React from 'react';
|
|
13
|
-
import { shallow } from 'enzyme';
|
|
14
|
-
import { Mode } from '@reltio/mdm-sdk';
|
|
15
|
-
import { EditModeAttributesPager } from '../../../EditModeAttributesPager';
|
|
16
|
-
import { attributeType, attributeValue } from '../../attributes.test-data';
|
|
17
|
-
import { MetaInfoForm } from './MetaInfoForm';
|
|
18
|
-
var onDeleteAttribute = jest.fn();
|
|
19
|
-
var onChangeAttribute = jest.fn();
|
|
20
|
-
var onAddAttributes = jest.fn();
|
|
21
|
-
var onCancel = jest.fn();
|
|
22
|
-
var onApply = jest.fn();
|
|
23
|
-
var setUp = function (attrValue, hasChanges) {
|
|
24
|
-
if (hasChanges === void 0) { hasChanges = false; }
|
|
25
|
-
var props = {
|
|
26
|
-
attributeType: attributeType,
|
|
27
|
-
attributeValue: attrValue || attributeValue,
|
|
28
|
-
imageAttributeFieldsOrder: {},
|
|
29
|
-
mode: Mode.Editing,
|
|
30
|
-
onDeleteAttribute: onDeleteAttribute,
|
|
31
|
-
onChangeAttribute: onChangeAttribute,
|
|
32
|
-
onAddAttributes: onAddAttributes,
|
|
33
|
-
onCancel: onCancel,
|
|
34
|
-
onApply: onApply,
|
|
35
|
-
hasChanges: hasChanges
|
|
36
|
-
};
|
|
37
|
-
return shallow(React.createElement(MetaInfoForm, __assign({}, props)));
|
|
38
|
-
};
|
|
39
|
-
describe('MetaInfoForm tests', function () {
|
|
40
|
-
it('should render not system attributes correctly', function () {
|
|
41
|
-
var component = setUp();
|
|
42
|
-
expect(component.find(EditModeAttributesPager).at(0).props()).toMatchObject({
|
|
43
|
-
parentUri: 'entities/15RRKaId/attributes/ImageGallery/3aL9d7zDM',
|
|
44
|
-
attributeType: {
|
|
45
|
-
label: 'String',
|
|
46
|
-
name: 'String',
|
|
47
|
-
type: 'String',
|
|
48
|
-
system: false,
|
|
49
|
-
uri: 'configuration/entityTypes/HCP/attributes/ImageGallery/attributes/String'
|
|
50
|
-
},
|
|
51
|
-
values: [
|
|
52
|
-
{
|
|
53
|
-
type: 'configuration/entityTypes/HCP/attributes/ImageGallery/attributes/String',
|
|
54
|
-
ov: true,
|
|
55
|
-
value: 'rere',
|
|
56
|
-
uri: 'entities/15RRKaId/attributes/ImageGallery/3aL9d7zDM/String/3aL9d8oMS'
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
type: 'configuration/entityTypes/HCP/attributes/ImageGallery/attributes/String',
|
|
60
|
-
value: '',
|
|
61
|
-
uri: 'entities/15RRKaId/attributes/ImageGallery/3aL9d7zDM/String/uri$$1626678443648'
|
|
62
|
-
}
|
|
63
|
-
],
|
|
64
|
-
mode: Mode.Editing,
|
|
65
|
-
onDeleteAttribute: onDeleteAttribute,
|
|
66
|
-
onChangeAttribute: onChangeAttribute,
|
|
67
|
-
onAddAttributes: onAddAttributes
|
|
68
|
-
});
|
|
69
|
-
expect(component.find(EditModeAttributesPager).at(1).props()).toMatchObject({
|
|
70
|
-
parentUri: 'entities/15RRKaId/attributes/ImageGallery/3aL9d7zDM',
|
|
71
|
-
attributeType: {
|
|
72
|
-
label: 'Date',
|
|
73
|
-
name: 'Date',
|
|
74
|
-
type: 'Date',
|
|
75
|
-
system: false,
|
|
76
|
-
uri: 'configuration/entityTypes/HCP/attributes/ImageGallery/attributes/Date'
|
|
77
|
-
},
|
|
78
|
-
values: [
|
|
79
|
-
{
|
|
80
|
-
value: '2021-07-07',
|
|
81
|
-
uri: 'entities/15RRKaId/attributes/ImageGallery/3aL9d7zDM/Date/uri$$1626678310141',
|
|
82
|
-
type: 'configuration/entityTypes/HCP/attributes/ImageGallery/attributes/Date'
|
|
83
|
-
}
|
|
84
|
-
],
|
|
85
|
-
mode: Mode.Editing,
|
|
86
|
-
onDeleteAttribute: onDeleteAttribute,
|
|
87
|
-
onChangeAttribute: onChangeAttribute,
|
|
88
|
-
onAddAttributes: onAddAttributes
|
|
89
|
-
});
|
|
90
|
-
expect(component.find(EditModeAttributesPager)).toHaveLength(2);
|
|
91
|
-
});
|
|
92
|
-
it('should render buttons and divider if attributeValue has not system attributes', function () {
|
|
93
|
-
var component = setUp();
|
|
94
|
-
expect(component.find('.divider')).toHaveLength(1);
|
|
95
|
-
expect(component.find('.actions')).toHaveLength(1);
|
|
96
|
-
});
|
|
97
|
-
it('should render buttons and divider if attributeValue has not notSystemAttributes, but hasChanges is "true"', function () {
|
|
98
|
-
var attrValue = {
|
|
99
|
-
value: {},
|
|
100
|
-
uri: 'uri'
|
|
101
|
-
};
|
|
102
|
-
var component = setUp(attrValue, true);
|
|
103
|
-
expect(component.find('.divider')).toHaveLength(1);
|
|
104
|
-
expect(component.find('.actions')).toHaveLength(1);
|
|
105
|
-
});
|
|
106
|
-
it('should not render buttons and divider if attributeValue has not notSystemAttributes and hasChanges is "false"', function () {
|
|
107
|
-
var attrValue = {
|
|
108
|
-
value: {},
|
|
109
|
-
uri: 'uri'
|
|
110
|
-
};
|
|
111
|
-
var component = setUp(attrValue);
|
|
112
|
-
expect(component.find('.divider')).toHaveLength(0);
|
|
113
|
-
expect(component.find('.actions')).toHaveLength(0);
|
|
114
|
-
});
|
|
115
|
-
it('should disable buttons if hasChanges is "false"', function () {
|
|
116
|
-
var component = setUp();
|
|
117
|
-
component
|
|
118
|
-
.find('.actions')
|
|
119
|
-
.children()
|
|
120
|
-
.forEach(function (node) {
|
|
121
|
-
expect(node.prop('disabled')).toBe(true);
|
|
122
|
-
});
|
|
123
|
-
});
|
|
124
|
-
it('onCancel handler should work correctly', function () {
|
|
125
|
-
var component = setUp();
|
|
126
|
-
component.find('.actions').childAt(0).simulate('click');
|
|
127
|
-
expect(onCancel).toHaveBeenCalled();
|
|
128
|
-
});
|
|
129
|
-
it('onApply handler should work correctly', function () {
|
|
130
|
-
var component = setUp();
|
|
131
|
-
component.find('.actions').childAt(1).simulate('click');
|
|
132
|
-
expect(onApply).toHaveBeenCalled();
|
|
133
|
-
});
|
|
134
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,99 +0,0 @@
|
|
|
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
|
-
import React from 'react';
|
|
13
|
-
import { shallow } from 'enzyme';
|
|
14
|
-
import { act } from 'react-dom/test-utils';
|
|
15
|
-
import { MoreAttributesButton } from '../../../MoreAttributesButton';
|
|
16
|
-
import { MetaInfoHeader } from './MetaInfoHeader';
|
|
17
|
-
var systemAttribute = {
|
|
18
|
-
label: 'Full image url (S3)',
|
|
19
|
-
name: 'Url',
|
|
20
|
-
type: 'String',
|
|
21
|
-
hidden: false,
|
|
22
|
-
important: false,
|
|
23
|
-
system: true,
|
|
24
|
-
searchable: true,
|
|
25
|
-
attributeOrdering: { orderingStrategy: 'LUD' },
|
|
26
|
-
uri: 'configuration/entityTypes/HCP/attributes/ImageGallery/attributes/Url',
|
|
27
|
-
skipInDataAccess: false,
|
|
28
|
-
access: [
|
|
29
|
-
'DELETE',
|
|
30
|
-
'UNMERGE',
|
|
31
|
-
'UPDATE',
|
|
32
|
-
'READ',
|
|
33
|
-
'INITIATE_CHANGE_REQUEST',
|
|
34
|
-
'MERGE',
|
|
35
|
-
'ACCEPT_CHANGE_REQUEST',
|
|
36
|
-
'CREATE'
|
|
37
|
-
]
|
|
38
|
-
};
|
|
39
|
-
var notSystemAttribute = {
|
|
40
|
-
label: 'String',
|
|
41
|
-
name: 'String',
|
|
42
|
-
type: 'String',
|
|
43
|
-
hidden: false,
|
|
44
|
-
important: false,
|
|
45
|
-
system: false,
|
|
46
|
-
attributeOrdering: { orderingStrategy: 'LUD' },
|
|
47
|
-
uri: 'configuration/entityTypes/HCP/attributes/ImageGallery/attributes/String',
|
|
48
|
-
skipInDataAccess: false,
|
|
49
|
-
access: [
|
|
50
|
-
'DELETE',
|
|
51
|
-
'UNMERGE',
|
|
52
|
-
'UPDATE',
|
|
53
|
-
'READ',
|
|
54
|
-
'INITIATE_CHANGE_REQUEST',
|
|
55
|
-
'MERGE',
|
|
56
|
-
'ACCEPT_CHANGE_REQUEST',
|
|
57
|
-
'CREATE'
|
|
58
|
-
]
|
|
59
|
-
};
|
|
60
|
-
var attributeType = {
|
|
61
|
-
attributes: [systemAttribute, notSystemAttribute]
|
|
62
|
-
};
|
|
63
|
-
var uri = 'entities/123/attributes/ImageGallery/1321';
|
|
64
|
-
var onAddAttributes = jest.fn();
|
|
65
|
-
var setUp = function (hasOnAddAttributes) {
|
|
66
|
-
var props = {
|
|
67
|
-
attributeType: attributeType,
|
|
68
|
-
uri: uri,
|
|
69
|
-
onAddAttributes: hasOnAddAttributes ? onAddAttributes : undefined
|
|
70
|
-
};
|
|
71
|
-
return shallow(React.createElement(MetaInfoHeader, __assign({}, props)));
|
|
72
|
-
};
|
|
73
|
-
describe('MetaInfoHeader tests', function () {
|
|
74
|
-
it('should render title className correctly if onAddAttributes exists', function () {
|
|
75
|
-
var component = setUp(true);
|
|
76
|
-
expect(component.find('.title').prop('className')).toBe('title canAdd');
|
|
77
|
-
});
|
|
78
|
-
it('should render title className correctly if onAddAttributes not exists', function () {
|
|
79
|
-
var component = setUp(false);
|
|
80
|
-
expect(component.find('.title').prop('className')).toBe('title');
|
|
81
|
-
});
|
|
82
|
-
it('should not render MoreAttributesButton and divider if onAddAttributes not exists', function () {
|
|
83
|
-
var component = setUp(false);
|
|
84
|
-
expect(component.find(MoreAttributesButton)).toHaveLength(0);
|
|
85
|
-
expect(component.find('.divider')).toHaveLength(0);
|
|
86
|
-
});
|
|
87
|
-
it('should render MoreAttributesButton and divider correctly if onAddAttributes exists', function () {
|
|
88
|
-
var component = setUp(true);
|
|
89
|
-
expect(component.find(MoreAttributesButton).prop('data')).toEqual([notSystemAttribute]);
|
|
90
|
-
expect(component.find('.divider')).toHaveLength(1);
|
|
91
|
-
});
|
|
92
|
-
it('onAddAttributes handler should work correctly', function () {
|
|
93
|
-
var component = setUp(true);
|
|
94
|
-
act(function () {
|
|
95
|
-
component.find(MoreAttributesButton).prop('onApply')([notSystemAttribute]);
|
|
96
|
-
});
|
|
97
|
-
expect(onAddAttributes).toHaveBeenCalledWith([{ attributeType: notSystemAttribute, parentUri: uri }]);
|
|
98
|
-
});
|
|
99
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { mount } from 'enzyme';
|
|
3
|
-
import { MetaInfoItem } from './MetaInfoItem';
|
|
4
|
-
describe('MetaInfoItem tests', function () {
|
|
5
|
-
it('should render span', function () {
|
|
6
|
-
var component = mount(React.createElement(MetaInfoItem, { title: 'Name', content: 'Content' }));
|
|
7
|
-
var title = component.find('.title');
|
|
8
|
-
expect(title).toHaveLength(1);
|
|
9
|
-
expect(title.text()).toBe('Name');
|
|
10
|
-
expect(component.find('.link')).toHaveLength(0);
|
|
11
|
-
var content = component.find('.content');
|
|
12
|
-
expect(content).toHaveLength(1);
|
|
13
|
-
expect(content.text()).toBe('Content');
|
|
14
|
-
});
|
|
15
|
-
it('should render link', function () {
|
|
16
|
-
var component = mount(React.createElement(MetaInfoItem, { title: 'Name', content: 'https://google.com', isLink: true }));
|
|
17
|
-
var title = component.find('.title');
|
|
18
|
-
expect(title).toHaveLength(1);
|
|
19
|
-
expect(title.text()).toBe('Name');
|
|
20
|
-
var link = component.find('.link');
|
|
21
|
-
expect(link).toHaveLength(1);
|
|
22
|
-
expect(link.prop('href')).toBe('https://google.com');
|
|
23
|
-
expect(component.find('.content')).toHaveLength(0);
|
|
24
|
-
});
|
|
25
|
-
it('should render child', function () {
|
|
26
|
-
var component = mount(React.createElement(MetaInfoItem, { title: 'Name' },
|
|
27
|
-
React.createElement("div", { className: 'onlyChild' }, "Sample! Not for sale!")));
|
|
28
|
-
var title = component.find('.title');
|
|
29
|
-
expect(title).toHaveLength(1);
|
|
30
|
-
expect(title.text()).toBe('Name');
|
|
31
|
-
expect(component.find('.content')).toHaveLength(1);
|
|
32
|
-
var child = component.find('.onlyChild');
|
|
33
|
-
expect(child.text()).toBe('Sample! Not for sale!');
|
|
34
|
-
expect(component.find('.link')).toHaveLength(0);
|
|
35
|
-
});
|
|
36
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|