@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.
Files changed (187) hide show
  1. package/AttributeListItem/AttributeListItem.d.ts +1 -1
  2. package/ChartTooltip/ChartTooltip.js +3 -3
  3. package/ColumnsSettings/ColumnsSettings.d.ts +2 -1
  4. package/ColumnsSettings/ColumnsSettings.js +2 -2
  5. package/ColumnsSettings/ColumnsSettings.test.js +14 -0
  6. package/ColumnsSettings/components/ColumnListItem/ColumnListItem.d.ts +11 -26
  7. package/ColumnsSettings/components/ColumnListItem/ColumnListItem.js +0 -14
  8. package/ColumnsSettings/components/ColumnsSettingsPopup/ColumnsSettingsPopup.d.ts +2 -1
  9. package/ColumnsSettings/components/ColumnsSettingsPopup/ColumnsSettingsPopup.js +2 -2
  10. package/DropDownMenuButton/DropDownMenuButton.js +1 -1
  11. package/HOCs/withAsyncMount/withAsyncMount.test.js +52 -52
  12. package/IgnoreButton/IgnoreButton.spec.js +109 -20
  13. package/Image/Image.d.ts +1 -1
  14. package/Image/Image.js +8 -8
  15. package/Image/Image.test.js +46 -51
  16. package/ImageActionsOverlay/ImageActionsOverlay.js +2 -1
  17. package/ImageActionsOverlay/ImageActionsOverlay.test.js +207 -125
  18. package/ImageActionsOverlay/components/CheckedIcon/CheckedIcon.js +1 -1
  19. package/ImageAttributesGallery/ImageAttributesGallery.test.js +525 -281
  20. package/ImageAttributesLine/ImageAttributesLine.js +1 -1
  21. package/ImageAttributesLine/ImageAttributesLine.test.js +187 -193
  22. package/ImageAttributesLine/imageAttributeValues.test-data.d.ts +10 -0
  23. package/ImageAttributesLine/imageAttributeValues.test-data.js +22 -0
  24. package/ImageAttributesLineEditor/ImageAttributesLineEditor.test.js +315 -298
  25. package/ImageDetailsView/ImageDetailsView.test.js +529 -55
  26. package/ImageDetailsView/attributes.test-data.d.ts +4 -1
  27. package/ImageDetailsView/attributes.test-data.js +98 -1
  28. package/ImageDetailsView/components/ImageDetailsViewCarousel/ImageDetailsViewCarousel.js +2 -2
  29. package/ImageDetailsView/components/MetaInfoItem/MetaInfoItem.js +1 -1
  30. package/ImageDetailsView/components/MetaInfoList/MetaInfoList.js +1 -1
  31. package/ImageDetailsView/components/Thumbnails/Thumbnails.js +1 -1
  32. package/ImageDetailsView/helpers.test.js +4 -4
  33. package/ImageGalleryDialog/ImageGalleryDialog.test.js +89 -46
  34. package/ImportButton/ImportButton.test.js +94 -24
  35. package/InlineAttributesList/InlineAttributesList.test.js +22 -62
  36. package/InlineAttributesList/attributes.test-data.d.ts +4 -2
  37. package/InlineAttributesList/attributes.test-data.js +40 -1
  38. package/InlineAttributesPager/InlineAttributesPager.d.ts +1 -2
  39. package/InlineAttributesPager/InlineAttributesPager.js +1 -4
  40. package/InlineAttributesPager/InlineAttributesPager.test.js +393 -183
  41. package/InlineComplexAttribute/InlineComplexAttribute.js +1 -1
  42. package/InlineComplexAttribute/InlineComplexAttribute.test.js +396 -182
  43. package/InlineImageAttribute/InlineImageAttribute.test.js +103 -55
  44. package/InlineNestedAttribute/InlineNestedAttribute.test.js +105 -43
  45. package/InlineReferenceAttribute/InlineReferenceAttribute.test.js +165 -107
  46. package/InlineSimpleAttribute/InlineSimpleAttribute.spec.js +352 -346
  47. package/InlineSimpleAttributeEditor/InlineSimpleAttributeEditor.test.js +285 -194
  48. package/InternalLink/InternalLink.test.js +41 -11
  49. package/LookupEditor/LookupEditor.test.js +180 -44
  50. package/LookupEditor/components/GroupedDropDownEditor/helpers.test.js +1 -1
  51. package/MapChart/MapChart.js +3 -8
  52. package/MapChart/MapChart.test.js +152 -188
  53. package/MapChart/components/Legend/Legend.js +3 -3
  54. package/MaskingSwitcher/MaskingSwitcher.js +1 -1
  55. package/MatchRulesBadge/MatchRulesBadge.test.js +93 -24
  56. package/SelectEditor/SelectEditor.d.ts +4 -10
  57. package/SelectEditor/SelectEditor.js +0 -4
  58. package/SelectEditor/SelectEditor.test.js +79 -9
  59. package/SelectionPopup/SelectionPopup.d.ts +2 -1
  60. package/SelectionPopup/SelectionPopup.js +3 -3
  61. package/SelectionPopup/SelectionPopup.spec.js +90 -30
  62. package/cjs/AttributeListItem/AttributeListItem.d.ts +1 -1
  63. package/cjs/ChartTooltip/ChartTooltip.js +3 -3
  64. package/cjs/ColumnsSettings/ColumnsSettings.d.ts +2 -1
  65. package/cjs/ColumnsSettings/ColumnsSettings.js +2 -2
  66. package/cjs/ColumnsSettings/ColumnsSettings.test.js +14 -0
  67. package/cjs/ColumnsSettings/components/ColumnListItem/ColumnListItem.d.ts +11 -26
  68. package/cjs/ColumnsSettings/components/ColumnListItem/ColumnListItem.js +0 -14
  69. package/cjs/ColumnsSettings/components/ColumnsSettingsPopup/ColumnsSettingsPopup.d.ts +2 -1
  70. package/cjs/ColumnsSettings/components/ColumnsSettingsPopup/ColumnsSettingsPopup.js +2 -2
  71. package/cjs/DropDownMenuButton/DropDownMenuButton.js +1 -1
  72. package/cjs/HOCs/withAsyncMount/withAsyncMount.test.js +56 -56
  73. package/cjs/IgnoreButton/IgnoreButton.spec.js +109 -20
  74. package/cjs/Image/Image.d.ts +1 -1
  75. package/cjs/Image/Image.js +8 -8
  76. package/cjs/Image/Image.test.js +46 -51
  77. package/cjs/ImageActionsOverlay/ImageActionsOverlay.js +2 -1
  78. package/cjs/ImageActionsOverlay/ImageActionsOverlay.test.js +207 -125
  79. package/cjs/ImageActionsOverlay/components/CheckedIcon/CheckedIcon.js +1 -1
  80. package/cjs/ImageAttributesGallery/ImageAttributesGallery.test.js +525 -281
  81. package/cjs/ImageAttributesLine/ImageAttributesLine.js +1 -1
  82. package/cjs/ImageAttributesLine/ImageAttributesLine.test.js +195 -224
  83. package/cjs/ImageAttributesLine/imageAttributeValues.test-data.d.ts +10 -0
  84. package/cjs/ImageAttributesLine/imageAttributeValues.test-data.js +23 -1
  85. package/cjs/ImageAttributesLineEditor/ImageAttributesLineEditor.test.js +316 -299
  86. package/cjs/ImageDetailsView/ImageDetailsView.test.js +529 -55
  87. package/cjs/ImageDetailsView/attributes.test-data.d.ts +4 -1
  88. package/cjs/ImageDetailsView/attributes.test-data.js +99 -2
  89. package/cjs/ImageDetailsView/components/ImageDetailsViewCarousel/ImageDetailsViewCarousel.js +2 -2
  90. package/cjs/ImageDetailsView/components/MetaInfoItem/MetaInfoItem.js +1 -1
  91. package/cjs/ImageDetailsView/components/MetaInfoList/MetaInfoList.js +1 -1
  92. package/cjs/ImageDetailsView/components/Thumbnails/Thumbnails.js +1 -1
  93. package/cjs/ImageDetailsView/helpers.test.js +3 -3
  94. package/cjs/ImageGalleryDialog/ImageGalleryDialog.test.js +89 -46
  95. package/cjs/ImportButton/ImportButton.test.js +94 -24
  96. package/cjs/InlineAttributesList/InlineAttributesList.test.js +22 -62
  97. package/cjs/InlineAttributesList/attributes.test-data.d.ts +4 -2
  98. package/cjs/InlineAttributesList/attributes.test-data.js +41 -2
  99. package/cjs/InlineAttributesPager/InlineAttributesPager.d.ts +1 -2
  100. package/cjs/InlineAttributesPager/InlineAttributesPager.js +1 -4
  101. package/cjs/InlineAttributesPager/InlineAttributesPager.test.js +393 -183
  102. package/cjs/InlineComplexAttribute/InlineComplexAttribute.js +1 -1
  103. package/cjs/InlineComplexAttribute/InlineComplexAttribute.test.js +395 -204
  104. package/cjs/InlineImageAttribute/InlineImageAttribute.test.js +103 -55
  105. package/cjs/InlineNestedAttribute/InlineNestedAttribute.test.js +105 -43
  106. package/cjs/InlineReferenceAttribute/InlineReferenceAttribute.test.js +164 -106
  107. package/cjs/InlineSimpleAttribute/InlineSimpleAttribute.spec.js +351 -345
  108. package/cjs/InlineSimpleAttributeEditor/InlineSimpleAttributeEditor.test.js +307 -193
  109. package/cjs/InternalLink/InternalLink.test.js +40 -10
  110. package/cjs/LookupEditor/LookupEditor.test.js +178 -65
  111. package/cjs/LookupEditor/components/GroupedDropDownEditor/helpers.test.js +1 -1
  112. package/cjs/MapChart/MapChart.js +3 -8
  113. package/cjs/MapChart/MapChart.test.js +152 -188
  114. package/cjs/MapChart/components/Legend/Legend.js +3 -3
  115. package/cjs/MaskingSwitcher/MaskingSwitcher.js +1 -1
  116. package/cjs/MatchRulesBadge/MatchRulesBadge.test.js +93 -24
  117. package/cjs/SelectEditor/SelectEditor.d.ts +4 -10
  118. package/cjs/SelectEditor/SelectEditor.js +0 -4
  119. package/cjs/SelectEditor/SelectEditor.test.js +79 -9
  120. package/cjs/SelectionPopup/SelectionPopup.d.ts +2 -1
  121. package/cjs/SelectionPopup/SelectionPopup.js +3 -3
  122. package/cjs/SelectionPopup/SelectionPopup.spec.js +90 -30
  123. package/cjs/hooks/useAsyncMount/useAsyncMount.d.ts +1 -1
  124. package/cjs/hooks/useAsyncMount/useAsyncMount.js +1 -1
  125. package/hooks/useAsyncMount/useAsyncMount.d.ts +1 -1
  126. package/hooks/useAsyncMount/useAsyncMount.js +1 -1
  127. package/package.json +1 -1
  128. package/HOCs/withTableContext/withTableContext.test.d.ts +0 -1
  129. package/HOCs/withTableContext/withTableContext.test.js +0 -41
  130. package/ImageAttributesGallery/components/GalleryView/GalleryView.test.d.ts +0 -1
  131. package/ImageAttributesGallery/components/GalleryView/GalleryView.test.js +0 -98
  132. package/ImageDetailsView/components/ImageDetailsViewCarousel/ImageDetailsViewCarousel.test.d.ts +0 -1
  133. package/ImageDetailsView/components/ImageDetailsViewCarousel/ImageDetailsViewCarousel.test.js +0 -99
  134. package/ImageDetailsView/components/ImageDetailsViewSidebar/ImageDetailsViewSidebar.test.d.ts +0 -1
  135. package/ImageDetailsView/components/ImageDetailsViewSidebar/ImageDetailsViewSidebar.test.js +0 -65
  136. package/ImageDetailsView/components/MetaInfo/MetaInfo.test.d.ts +0 -1
  137. package/ImageDetailsView/components/MetaInfo/MetaInfo.test.js +0 -306
  138. package/ImageDetailsView/components/MetaInfoForm/MetaInfoForm.test.d.ts +0 -1
  139. package/ImageDetailsView/components/MetaInfoForm/MetaInfoForm.test.js +0 -134
  140. package/ImageDetailsView/components/MetaInfoHeader/MetaInfoHeader.test.d.ts +0 -1
  141. package/ImageDetailsView/components/MetaInfoHeader/MetaInfoHeader.test.js +0 -99
  142. package/ImageDetailsView/components/MetaInfoItem/MetaInfoItem.test.d.ts +0 -1
  143. package/ImageDetailsView/components/MetaInfoItem/MetaInfoItem.test.js +0 -36
  144. package/ImageDetailsView/components/MetaInfoList/MetaInfoList.test.d.ts +0 -1
  145. package/ImageDetailsView/components/MetaInfoList/MetaInfoList.test.js +0 -161
  146. package/ImageDetailsView/components/Thumbnails/Thumbnails.test.d.ts +0 -1
  147. package/ImageDetailsView/components/Thumbnails/Thumbnails.test.js +0 -76
  148. package/InlineAttributesPager/components/InlineImageAttributesBlock/InlineImageAttributesBlock.test.d.ts +0 -1
  149. package/InlineAttributesPager/components/InlineImageAttributesBlock/InlineImageAttributesBlock.test.js +0 -104
  150. package/InlineAttributesPager/components/InlineNestedAttributesBlock/InlineNestedAttributesBlock.test.d.ts +0 -1
  151. package/InlineAttributesPager/components/InlineNestedAttributesBlock/InlineNestedAttributesBlock.test.js +0 -114
  152. package/InlineAttributesPager/components/InlineReferenceAttributesBlock/InlineReferenceAttributesBlock.test.d.ts +0 -1
  153. package/InlineAttributesPager/components/InlineReferenceAttributesBlock/InlineReferenceAttributesBlock.test.js +0 -177
  154. package/InlineSimpleAttribute/components/CrosswalkMenuItem/CrosswalkMenuItem.spec.d.ts +0 -1
  155. package/InlineSimpleAttribute/components/CrosswalkMenuItem/CrosswalkMenuItem.spec.js +0 -52
  156. package/LookupEditor/components/GroupedDropDownEditor/GroupedDropDownEditor.test.d.ts +0 -1
  157. package/LookupEditor/components/GroupedDropDownEditor/GroupedDropDownEditor.test.js +0 -37
  158. package/cjs/HOCs/withTableContext/withTableContext.test.d.ts +0 -1
  159. package/cjs/HOCs/withTableContext/withTableContext.test.js +0 -46
  160. package/cjs/ImageAttributesGallery/components/GalleryView/GalleryView.test.d.ts +0 -1
  161. package/cjs/ImageAttributesGallery/components/GalleryView/GalleryView.test.js +0 -103
  162. package/cjs/ImageDetailsView/components/ImageDetailsViewCarousel/ImageDetailsViewCarousel.test.d.ts +0 -1
  163. package/cjs/ImageDetailsView/components/ImageDetailsViewCarousel/ImageDetailsViewCarousel.test.js +0 -104
  164. package/cjs/ImageDetailsView/components/ImageDetailsViewSidebar/ImageDetailsViewSidebar.test.d.ts +0 -1
  165. package/cjs/ImageDetailsView/components/ImageDetailsViewSidebar/ImageDetailsViewSidebar.test.js +0 -70
  166. package/cjs/ImageDetailsView/components/MetaInfo/MetaInfo.test.d.ts +0 -1
  167. package/cjs/ImageDetailsView/components/MetaInfo/MetaInfo.test.js +0 -311
  168. package/cjs/ImageDetailsView/components/MetaInfoForm/MetaInfoForm.test.d.ts +0 -1
  169. package/cjs/ImageDetailsView/components/MetaInfoForm/MetaInfoForm.test.js +0 -139
  170. package/cjs/ImageDetailsView/components/MetaInfoHeader/MetaInfoHeader.test.d.ts +0 -1
  171. package/cjs/ImageDetailsView/components/MetaInfoHeader/MetaInfoHeader.test.js +0 -104
  172. package/cjs/ImageDetailsView/components/MetaInfoItem/MetaInfoItem.test.d.ts +0 -1
  173. package/cjs/ImageDetailsView/components/MetaInfoItem/MetaInfoItem.test.js +0 -41
  174. package/cjs/ImageDetailsView/components/MetaInfoList/MetaInfoList.test.d.ts +0 -1
  175. package/cjs/ImageDetailsView/components/MetaInfoList/MetaInfoList.test.js +0 -166
  176. package/cjs/ImageDetailsView/components/Thumbnails/Thumbnails.test.d.ts +0 -1
  177. package/cjs/ImageDetailsView/components/Thumbnails/Thumbnails.test.js +0 -81
  178. package/cjs/InlineAttributesPager/components/InlineImageAttributesBlock/InlineImageAttributesBlock.test.d.ts +0 -1
  179. package/cjs/InlineAttributesPager/components/InlineImageAttributesBlock/InlineImageAttributesBlock.test.js +0 -109
  180. package/cjs/InlineAttributesPager/components/InlineNestedAttributesBlock/InlineNestedAttributesBlock.test.d.ts +0 -1
  181. package/cjs/InlineAttributesPager/components/InlineNestedAttributesBlock/InlineNestedAttributesBlock.test.js +0 -119
  182. package/cjs/InlineAttributesPager/components/InlineReferenceAttributesBlock/InlineReferenceAttributesBlock.test.d.ts +0 -1
  183. package/cjs/InlineAttributesPager/components/InlineReferenceAttributesBlock/InlineReferenceAttributesBlock.test.js +0 -182
  184. package/cjs/InlineSimpleAttribute/components/CrosswalkMenuItem/CrosswalkMenuItem.spec.d.ts +0 -1
  185. package/cjs/InlineSimpleAttribute/components/CrosswalkMenuItem/CrosswalkMenuItem.spec.js +0 -57
  186. package/cjs/LookupEditor/components/GroupedDropDownEditor/GroupedDropDownEditor.test.d.ts +0 -1
  187. package/cjs/LookupEditor/components/GroupedDropDownEditor/GroupedDropDownEditor.test.js +0 -42
@@ -1,18 +1,88 @@
1
1
  "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
14
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
15
+ return new (P || (P = Promise))(function (resolve, reject) {
16
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
17
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
18
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
19
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
20
+ });
21
+ };
22
+ var __generator = (this && this.__generator) || function (thisArg, body) {
23
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
24
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
25
+ function verb(n) { return function (v) { return step([n, v]); }; }
26
+ function step(op) {
27
+ if (f) throw new TypeError("Generator is already executing.");
28
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
29
+ 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;
30
+ if (y = 0, t) op = [op[0] & 2, t.value];
31
+ switch (op[0]) {
32
+ case 0: case 1: t = op; break;
33
+ case 4: _.label++; return { value: op[1], done: false };
34
+ case 5: _.label++; y = op[1]; op = [0]; continue;
35
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
36
+ default:
37
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
38
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
39
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
40
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
41
+ if (t[2]) _.ops.pop();
42
+ _.trys.pop(); continue;
43
+ }
44
+ op = body.call(thisArg, _);
45
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
46
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
47
+ }
48
+ };
2
49
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
50
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
51
  };
5
52
  Object.defineProperty(exports, "__esModule", { value: true });
6
53
  var react_1 = __importDefault(require("react"));
7
- var build_1 = require("enzyme/build");
8
- var DropDownEditor_1 = require("../DropDownEditor");
54
+ var react_2 = require("@testing-library/react");
55
+ var user_event_1 = __importDefault(require("@testing-library/user-event"));
9
56
  var SelectEditor_1 = require("./SelectEditor");
10
57
  describe('SelectEditor', function () {
11
- it('should render DropDownEditor', function () {
12
- var entries = [{ value: 'String1' }, { value: 'String2' }, { value: 'String3' }], value = 'String2';
13
- var wrapper = (0, build_1.shallow)(react_1.default.createElement(SelectEditor_1.SelectEditor, { value: value, entries: entries }));
14
- var dropDown = wrapper.find(DropDownEditor_1.DropDownEditor);
15
- expect(dropDown.prop('value')).toBe(value);
16
- expect(dropDown.prop('entries')).toEqual(entries);
17
- });
58
+ var defaultProps = {
59
+ value: 'String1',
60
+ classes: { root: 'customRoot' },
61
+ entries: [{ value: 'String1' }, { value: 'String2' }, { value: 'String3' }],
62
+ onChange: jest.fn()
63
+ };
64
+ it('should render DropDownEditor', function () { return __awaiter(void 0, void 0, void 0, function () {
65
+ var user, button;
66
+ return __generator(this, function (_a) {
67
+ switch (_a.label) {
68
+ case 0:
69
+ user = user_event_1.default.setup();
70
+ (0, react_2.render)(react_1.default.createElement(SelectEditor_1.SelectEditor, __assign({}, defaultProps)));
71
+ expect(react_2.screen.getByText('String1')).toBeInTheDocument();
72
+ expect(react_2.screen.queryByText('String2')).not.toBeInTheDocument();
73
+ button = react_2.screen.getByRole('button');
74
+ expect(button).toHaveClass('customRoot');
75
+ return [4 /*yield*/, user.click(button)];
76
+ case 1:
77
+ _a.sent();
78
+ expect(react_2.screen.getByText('String2')).toBeInTheDocument();
79
+ expect(react_2.screen.getByText('String3')).toBeInTheDocument();
80
+ return [4 /*yield*/, user.click(react_2.screen.getByText('String3'))];
81
+ case 2:
82
+ _a.sent();
83
+ expect(defaultProps.onChange).toHaveBeenCalledWith('String3');
84
+ return [2 /*return*/];
85
+ }
86
+ });
87
+ }); });
18
88
  });
@@ -11,8 +11,9 @@ type Props = {
11
11
  className?: string;
12
12
  hideTitle?: boolean;
13
13
  hideSearchInput?: boolean;
14
+ inputPlaceholder?: string;
14
15
  headerPlacement?: 'top' | 'bottom';
15
16
  searchInputRef?: React.Ref<unknown>;
16
17
  } & PopoverProps;
17
- export declare const SelectionPopup: ({ title, className, onSearch, hideTitle, hideSearchInput, headerPlacement, containerWidth, containerHeight, searchInputOnKeyDown, children, searchInputRef, anchorOrigin, transformOrigin, ...otherProps }: Props) => React.JSX.Element;
18
+ export declare const SelectionPopup: ({ title, className, onSearch, hideTitle, hideSearchInput, inputPlaceholder, headerPlacement, containerWidth, containerHeight, searchInputOnKeyDown, children, searchInputRef, anchorOrigin, transformOrigin, ...otherProps }: Props) => React.JSX.Element;
18
19
  export {};
@@ -35,18 +35,18 @@ var styles_1 = require("./styles");
35
35
  var styles_2 = require("@mui/styles");
36
36
  var SelectionPopup = function (_a) {
37
37
  var _b;
38
- var title = _a.title, className = _a.className, onSearch = _a.onSearch, hideTitle = _a.hideTitle, hideSearchInput = _a.hideSearchInput, _c = _a.headerPlacement, headerPlacement = _c === void 0 ? 'top' : _c, containerWidth = _a.containerWidth, containerHeight = _a.containerHeight, searchInputOnKeyDown = _a.searchInputOnKeyDown, children = _a.children, searchInputRef = _a.searchInputRef, _d = _a.anchorOrigin, anchorOrigin = _d === void 0 ? {
38
+ var title = _a.title, className = _a.className, onSearch = _a.onSearch, hideTitle = _a.hideTitle, hideSearchInput = _a.hideSearchInput, inputPlaceholder = _a.inputPlaceholder, _c = _a.headerPlacement, headerPlacement = _c === void 0 ? 'top' : _c, containerWidth = _a.containerWidth, containerHeight = _a.containerHeight, searchInputOnKeyDown = _a.searchInputOnKeyDown, children = _a.children, searchInputRef = _a.searchInputRef, _d = _a.anchorOrigin, anchorOrigin = _d === void 0 ? {
39
39
  vertical: 'top',
40
40
  horizontal: 'right'
41
41
  } : _d, _e = _a.transformOrigin, transformOrigin = _e === void 0 ? {
42
42
  vertical: 'top',
43
43
  horizontal: 'right'
44
- } : _e, otherProps = __rest(_a, ["title", "className", "onSearch", "hideTitle", "hideSearchInput", "headerPlacement", "containerWidth", "containerHeight", "searchInputOnKeyDown", "children", "searchInputRef", "anchorOrigin", "transformOrigin"]);
44
+ } : _e, otherProps = __rest(_a, ["title", "className", "onSearch", "hideTitle", "hideSearchInput", "inputPlaceholder", "headerPlacement", "containerWidth", "containerHeight", "searchInputOnKeyDown", "children", "searchInputRef", "anchorOrigin", "transformOrigin"]);
45
45
  var classes = (0, styles_1.useStyles)({ containerWidth: containerWidth, containerHeight: containerHeight });
46
46
  var currentTheme = (0, styles_2.useTheme)();
47
47
  var header = (react_1.default.createElement(react_1.default.Fragment, null,
48
48
  !hideTitle && react_1.default.createElement("div", { className: classes.header }, title),
49
- !hideSearchInput && (react_1.default.createElement(SearchInput_1.SearchInput, { onSearch: onSearch, autofocus: true, onKeyDown: searchInputOnKeyDown, inputRef: searchInputRef, classes: { root: classes.searchInputContainer }, placeholder: ui_i18n_1.default.text('Search & add attributes'), height: 40 }))));
49
+ !hideSearchInput && (react_1.default.createElement(SearchInput_1.SearchInput, { onSearch: onSearch, autofocus: true, onKeyDown: searchInputOnKeyDown, inputRef: searchInputRef, classes: { root: classes.searchInputContainer }, placeholder: inputPlaceholder || ui_i18n_1.default.text('Search & add attributes'), height: 40 }))));
50
50
  return (react_1.default.createElement(Popover_1.default, __assign({ anchorOrigin: anchorOrigin, transformOrigin: transformOrigin, "data-mui-color-scheme": (_b = currentTheme === null || currentTheme === void 0 ? void 0 : currentTheme.palette) === null || _b === void 0 ? void 0 : _b.mode }, otherProps),
51
51
  react_1.default.createElement("div", { className: (0, classnames_1.default)(classes.container, className), style: { width: containerWidth } },
52
52
  headerPlacement === 'top' && header,
@@ -10,53 +10,113 @@ var __assign = (this && this.__assign) || function () {
10
10
  };
11
11
  return __assign.apply(this, arguments);
12
12
  };
13
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
14
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
15
+ return new (P || (P = Promise))(function (resolve, reject) {
16
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
17
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
18
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
19
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
20
+ });
21
+ };
22
+ var __generator = (this && this.__generator) || function (thisArg, body) {
23
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
24
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
25
+ function verb(n) { return function (v) { return step([n, v]); }; }
26
+ function step(op) {
27
+ if (f) throw new TypeError("Generator is already executing.");
28
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
29
+ 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;
30
+ if (y = 0, t) op = [op[0] & 2, t.value];
31
+ switch (op[0]) {
32
+ case 0: case 1: t = op; break;
33
+ case 4: _.label++; return { value: op[1], done: false };
34
+ case 5: _.label++; y = op[1]; op = [0]; continue;
35
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
36
+ default:
37
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
38
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
39
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
40
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
41
+ if (t[2]) _.ops.pop();
42
+ _.trys.pop(); continue;
43
+ }
44
+ op = body.call(thisArg, _);
45
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
46
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
47
+ }
48
+ };
13
49
  var __importDefault = (this && this.__importDefault) || function (mod) {
14
50
  return (mod && mod.__esModule) ? mod : { "default": mod };
15
51
  };
16
52
  Object.defineProperty(exports, "__esModule", { value: true });
17
53
  var react_1 = __importDefault(require("react"));
18
- var enzyme_1 = require("enzyme");
19
- var Popover_1 = __importDefault(require("@mui/material/Popover"));
54
+ var react_2 = require("@testing-library/react");
55
+ var user_event_1 = __importDefault(require("@testing-library/user-event"));
20
56
  var SelectionPopup_1 = require("./SelectionPopup");
21
- var SearchInput_1 = require("../SearchInput");
22
57
  describe('SelectionPopup tests', function () {
23
58
  var defaultProps = {
59
+ title: 'Title',
24
60
  anchorEl: document.createElement('div'),
25
- open: true
61
+ open: true,
62
+ containerWidth: 100,
63
+ containerHeight: 100,
64
+ children: react_1.default.createElement("div", { "data-reltio-id": "children" }),
65
+ onClose: jest.fn(),
66
+ onSearch: jest.fn(),
67
+ searchInputOnKeyDown: jest.fn()
26
68
  };
27
- it('should render main components correctly', function () {
28
- var props = __assign(__assign({}, defaultProps), { children: react_1.default.createElement("div", { className: 'testChildren' }), title: 'Title', onSearch: jest.fn(), searchInputOnKeyDown: jest.fn(), onClose: jest.fn() });
29
- var component = (0, enzyme_1.shallow)(react_1.default.createElement(SelectionPopup_1.SelectionPopup, __assign({}, props)));
30
- var popover = component.find(Popover_1.default);
31
- expect(popover.props()).toMatchObject({
32
- open: props.open,
33
- onClose: props.onClose
34
- });
35
- expect(popover.find('.header').text()).toBe(props.title);
36
- expect(popover.find(SearchInput_1.SearchInput).props()).toMatchObject({
37
- onKeyDown: props.searchInputOnKeyDown,
38
- onSearch: props.onSearch
69
+ var setUp = function (props) {
70
+ if (props === void 0) { props = {}; }
71
+ var user = user_event_1.default.setup();
72
+ return __assign({ user: user }, (0, react_2.render)(react_1.default.createElement(SelectionPopup_1.SelectionPopup, __assign({}, defaultProps, props))));
73
+ };
74
+ it('should render main components correctly', function () { return __awaiter(void 0, void 0, void 0, function () {
75
+ var user, textbox, backdrop;
76
+ return __generator(this, function (_a) {
77
+ switch (_a.label) {
78
+ case 0:
79
+ user = setUp().user;
80
+ textbox = react_2.screen.getByRole('textbox');
81
+ expect(textbox).toHaveAttribute('placeholder', 'Search & add attributes');
82
+ expect(react_2.screen.getByText('Title')).toBeInTheDocument();
83
+ expect(react_2.screen.getByTestId('children')).toBeInTheDocument();
84
+ return [4 /*yield*/, user.type(textbox, 'test')];
85
+ case 1:
86
+ _a.sent();
87
+ expect(defaultProps.onSearch).toHaveBeenCalledWith('test');
88
+ expect(defaultProps.searchInputOnKeyDown).toHaveBeenCalledTimes(4);
89
+ backdrop = react_2.screen.getByRole('presentation').firstChild;
90
+ return [4 /*yield*/, user.click(backdrop)];
91
+ case 2:
92
+ _a.sent();
93
+ expect(defaultProps.onClose).toHaveBeenCalled();
94
+ return [2 /*return*/];
95
+ }
39
96
  });
40
- expect(popover.find('.testChildren').length).toBe(1);
41
- });
97
+ }); });
42
98
  it('should hide title if props.hideTitle is true', function () {
43
- var component = (0, enzyme_1.shallow)(react_1.default.createElement(SelectionPopup_1.SelectionPopup, __assign({}, defaultProps, { hideTitle: true })));
44
- expect(component.find('.header')).toHaveLength(0);
99
+ setUp({ hideTitle: true });
100
+ expect(react_2.screen.queryByText('Title')).not.toBeInTheDocument();
45
101
  });
46
102
  it('should hide search input if props.hideSearchInput is true', function () {
47
- var component = (0, enzyme_1.shallow)(react_1.default.createElement(SelectionPopup_1.SelectionPopup, __assign({}, defaultProps, { hideSearchInput: true })));
48
- expect(component.find(SearchInput_1.SearchInput)).toHaveLength(0);
103
+ setUp({ hideSearchInput: true });
104
+ expect(react_2.screen.queryByRole('textbox')).not.toBeInTheDocument();
105
+ });
106
+ it('should use placeholder from props.inputPlaceholder', function () {
107
+ setUp({ inputPlaceholder: 'test placeholder' });
108
+ expect(react_2.screen.getByRole('textbox')).toHaveAttribute('placeholder', 'test placeholder');
49
109
  });
50
110
  it('should render header at the top if props.headerPlacement is "top"', function () {
51
- var component = (0, enzyme_1.shallow)(react_1.default.createElement(SelectionPopup_1.SelectionPopup, __assign({}, defaultProps, { headerPlacement: "top" })));
52
- var content = component.find('.container').children();
53
- expect(content.at(0).prop('className')).toBe('header');
54
- expect(content.at(1).prop('placeholder')).toBe('Search & add attributes');
111
+ setUp({ headerPlacement: 'top' });
112
+ var container = react_2.screen.getByRole('presentation').querySelector('.container');
113
+ expect(container.firstChild).toHaveClass('header');
114
+ expect(container.lastChild).toHaveClass('list');
55
115
  });
56
116
  it('should render header at the bottom if props.headerPlacement is "bottom"', function () {
57
- var component = (0, enzyme_1.shallow)(react_1.default.createElement(SelectionPopup_1.SelectionPopup, __assign({}, defaultProps, { headerPlacement: "bottom" })));
58
- var content = component.find('.container').children();
59
- expect(content.at(content.length - 2).prop('className')).toBe('header');
60
- expect(content.at(content.length - 1).prop('placeholder')).toBe('Search & add attributes');
117
+ setUp({ headerPlacement: 'bottom' });
118
+ var container = react_2.screen.getByRole('presentation').querySelector('.container');
119
+ expect(container.firstChild).toHaveClass('list');
120
+ expect(container.lastChild).toHaveClass('searchInputContainer');
61
121
  });
62
122
  });
@@ -1 +1 @@
1
- export function useAsyncMount(): boolean;
1
+ export declare const useAsyncMount: () => boolean;
@@ -11,7 +11,7 @@ var useAsyncMount = function () {
11
11
  if (isFirstRunRef.current) {
12
12
  queueSize++;
13
13
  }
14
- var timerRef = (0, react_1.useRef)();
14
+ var timerRef = (0, react_1.useRef)(null);
15
15
  (0, react_1.useEffect)(function () {
16
16
  queueSize--;
17
17
  if (!shouldMount) {
@@ -1 +1 @@
1
- export function useAsyncMount(): boolean;
1
+ export declare const useAsyncMount: () => boolean;
@@ -8,7 +8,7 @@ export var useAsyncMount = function () {
8
8
  if (isFirstRunRef.current) {
9
9
  queueSize++;
10
10
  }
11
- var timerRef = useRef();
11
+ var timerRef = useRef(null);
12
12
  useEffect(function () {
13
13
  queueSize--;
14
14
  if (!shouldMount) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reltio/components",
3
- "version": "1.4.2050",
3
+ "version": "1.4.2052",
4
4
  "license": "SEE LICENSE IN LICENSE FILE",
5
5
  "main": "./cjs/index.js",
6
6
  "module": "./index.js",
@@ -1 +0,0 @@
1
- export {};
@@ -1,41 +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 { withTableContext } from './withTableContext';
15
- import { BasicTableContext } from '../../contexts/BasicTableContext';
16
- describe('withTableContext behavior', function () {
17
- it('should return original cell renderer if context selector is not provided', function () {
18
- var CellRenderer = function () { };
19
- expect(withTableContext(undefined)(CellRenderer)).toBe(CellRenderer);
20
- expect(withTableContext(null)(CellRenderer)).toBe(CellRenderer);
21
- });
22
- it('should wrap original cell renderer in BasicTableContext if context selector is provided', function () {
23
- var CellRenderer = function () { return 'Cell Value'; };
24
- var contextSelector = function (context) { return ({ cellContext: context.cellContext }); };
25
- var CellRendererWithContext = withTableContext(contextSelector)(CellRenderer);
26
- var cellContext = 'test';
27
- var wrapper = mount(React.createElement(BasicTableContext.Provider, { value: { cellContext: cellContext } },
28
- React.createElement(CellRendererWithContext, null)));
29
- expect(wrapper.find('CellRenderer').prop('cellContext')).toBe(cellContext);
30
- });
31
- it('should call context selector with own props as second param', function () {
32
- var CellRenderer = function () { return 'Cell Value'; };
33
- var contextSelector = jest.fn(function (context) { return ({ cellContext: context.cellContext }); });
34
- var CellRendererWithContext = withTableContext(contextSelector)(CellRenderer);
35
- var cellContext = 'test';
36
- var ownProps = { someProp: true };
37
- mount(React.createElement(BasicTableContext.Provider, { value: { cellContext: cellContext } },
38
- React.createElement(CellRendererWithContext, __assign({}, ownProps))));
39
- expect(contextSelector).toHaveBeenCalledWith({ cellContext: cellContext }, ownProps);
40
- });
41
- });
@@ -1,98 +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 { range } from 'ramda';
15
- import { act } from 'react-dom/test-utils';
16
- import { GalleryView } from './GalleryView';
17
- import { Image } from '../../../Image';
18
- import { ImageActionsOverlay } from '../../../ImageActionsOverlay';
19
- describe('GalleryView tests', function () {
20
- var generateItems = function (count) {
21
- return range(0, count).map(function (i) { return ({
22
- id: "id".concat(i),
23
- src: "image".concat(i, ".jpg")
24
- }); });
25
- };
26
- var defaultProps = {
27
- items: generateItems(3),
28
- selectedItems: [],
29
- onSelectImage: jest.fn(),
30
- onDeselectImage: jest.fn(),
31
- onShareLink: jest.fn(),
32
- onSetAsDefault: jest.fn(),
33
- onDownload: jest.fn(),
34
- onClickImage: jest.fn(),
35
- onDelete: jest.fn()
36
- };
37
- it('should render main parts', function () {
38
- var component = mount(React.createElement(GalleryView, __assign({}, defaultProps)));
39
- expect(component.find(Image)).toHaveLength(3);
40
- expect(component.find(ImageActionsOverlay)).toHaveLength(0);
41
- });
42
- it('should call main prop functions from overlay', function () {
43
- var component = mount(React.createElement(GalleryView, __assign({}, defaultProps)));
44
- act(function () {
45
- component.find('.image').first().simulate('load');
46
- });
47
- component.update();
48
- act(function () {
49
- component.find(Image).first().simulate('mouseEnter');
50
- });
51
- component.update();
52
- var imageActionsOverlay = component.find(ImageActionsOverlay).first();
53
- var onSelect = imageActionsOverlay.prop('onSelect');
54
- onSelect();
55
- expect(defaultProps.onSelectImage).toHaveBeenCalledWith('id0');
56
- var onDeselect = imageActionsOverlay.prop('onDeselect');
57
- onDeselect();
58
- expect(defaultProps.onDeselectImage).toHaveBeenCalledWith('id0');
59
- var onShareLink = imageActionsOverlay.prop('onShareLink');
60
- onShareLink();
61
- expect(defaultProps.onShareLink).toHaveBeenCalledWith('id0');
62
- var onSetAsDefault = imageActionsOverlay.prop('onSetAsDefault');
63
- onSetAsDefault();
64
- expect(defaultProps.onSetAsDefault).toHaveBeenCalledWith('id0');
65
- var onDownload = imageActionsOverlay.prop('onDownload');
66
- onDownload();
67
- expect(defaultProps.onDownload).toHaveBeenCalledWith('id0');
68
- var onDelete = imageActionsOverlay.prop('onDelete');
69
- onDelete();
70
- expect(defaultProps.onDelete).toHaveBeenCalledWith('id0');
71
- var onClick = imageActionsOverlay.prop('onClick');
72
- onClick();
73
- expect(defaultProps.onClickImage).toHaveBeenCalledWith('id0');
74
- });
75
- it('should call onClickImage from Image', function () {
76
- var component = mount(React.createElement(GalleryView, __assign({}, defaultProps)));
77
- act(function () {
78
- component.find('.image').first().simulate('load');
79
- });
80
- component.update();
81
- var onClick = component.find('.image').first().prop('onClick');
82
- onClick();
83
- expect(defaultProps.onClickImage).toHaveBeenCalledWith('id0');
84
- });
85
- it('should not provide onDelete if onDelete is undefined', function () {
86
- var component = mount(React.createElement(GalleryView, __assign({}, defaultProps, { onDelete: undefined })));
87
- act(function () {
88
- component.find('.image').first().simulate('load');
89
- });
90
- component.update();
91
- act(function () {
92
- component.find(Image).first().simulate('mouseEnter');
93
- });
94
- component.update();
95
- var imageActionsOverlay = component.find(ImageActionsOverlay).first();
96
- expect(imageActionsOverlay.prop('onDelete')).toBeUndefined();
97
- });
98
- });
@@ -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 { mount } from 'enzyme';
14
- import { Image } from '../../../Image';
15
- import { ImageDetailsViewCarousel } from './ImageDetailsViewCarousel';
16
- describe('DetailsViewCarousel tests', function () {
17
- it('should render 5 images and render correct main image', function () {
18
- var attributeValues = [
19
- { uri: '1', value: { UrlPreview: [{ value: '#0', uri: '1' }] } },
20
- { uri: '2', value: { UrlPreview: [{ value: '#1', uri: '2' }] } },
21
- { uri: '3', value: { UrlPreview: [{ value: '#2', uri: '3' }] } },
22
- { uri: '4', value: { UrlPreview: [{ value: '#3', uri: '4' }] } },
23
- { uri: '5', value: { UrlPreview: [{ value: '#4', uri: '5' }] } }
24
- ];
25
- var component = mount(React.createElement(ImageDetailsViewCarousel, { attributeValueIndex: 3, setAttributeValueIndex: jest.fn(), attributeValues: attributeValues }));
26
- var images = component.find(Image);
27
- expect(images.filter('.thumb').length).toBe(5);
28
- expect(images.filter('.mainImage').prop('src')).toBe('#3');
29
- });
30
- it('should change currentImageIndex on prevButtonClick', function () {
31
- var attributeValueIndex = 3;
32
- var setAttributeValueIndex = function (index) {
33
- attributeValueIndex = index;
34
- };
35
- var attributeValues = [
36
- { uri: '1', value: { UrlPreview: [{ value: '#0', uri: '1' }] } },
37
- { uri: '2', value: { UrlPreview: [{ value: '#1', uri: '2' }] } },
38
- { uri: '3', value: { UrlPreview: [{ value: '#2', uri: '3' }] } },
39
- { uri: '4', value: { UrlPreview: [{ value: '#3', uri: '4' }] } },
40
- { uri: '5', value: { UrlPreview: [{ value: '#4', uri: '5' }] } }
41
- ];
42
- var props = { attributeValueIndex: attributeValueIndex, setAttributeValueIndex: setAttributeValueIndex, attributeValues: attributeValues };
43
- var component = mount(React.createElement(ImageDetailsViewCarousel, __assign({}, props)));
44
- var images = component.find(Image);
45
- expect(images.filter('.thumb').length).toBe(5);
46
- expect(images.filter('.mainImage').prop('src')).toBe('#3');
47
- var prevButton = component.find('button.arrowButtonPrev');
48
- prevButton.simulate('click');
49
- component.setProps(__assign(__assign({}, props), { attributeValueIndex: attributeValueIndex }));
50
- component.update();
51
- expect(component.find(Image).filter('.mainImage').prop('src')).toBe('#2');
52
- });
53
- it('should change currentImageIndex on nextButtonClick', function () {
54
- var attributeValueIndex = 3;
55
- var setAttributeValueIndex = function (index) {
56
- attributeValueIndex = index;
57
- };
58
- var attributeValues = [
59
- { uri: '1', value: { UrlPreview: [{ value: '#0', uri: '1' }] } },
60
- { uri: '2', value: { UrlPreview: [{ value: '#1', uri: '2' }] } },
61
- { uri: '3', value: { UrlPreview: [{ value: '#2', uri: '3' }] } },
62
- { uri: '4', value: { UrlPreview: [{ value: '#3', uri: '4' }] } },
63
- { uri: '5', value: { UrlPreview: [{ value: '#4', uri: '5' }] } }
64
- ];
65
- var props = { attributeValueIndex: attributeValueIndex, setAttributeValueIndex: setAttributeValueIndex, attributeValues: attributeValues };
66
- var component = mount(React.createElement(ImageDetailsViewCarousel, __assign({}, props)));
67
- var images = component.find(Image);
68
- expect(images.filter('.thumb').length).toBe(5);
69
- expect(images.filter('.mainImage').prop('src')).toBe('#3');
70
- var nextButton = component.find('button.arrowButtonNext');
71
- nextButton.simulate('click');
72
- component.setProps(__assign(__assign({}, props), { attributeValueIndex: attributeValueIndex }));
73
- component.update();
74
- expect(component.find(Image).filter('.mainImage').prop('src')).toBe('#4');
75
- });
76
- it('should change currentImageIndex on click on image at carousel', function () {
77
- var attributeValueIndex = 3;
78
- var setAttributeValueIndex = function (index) {
79
- attributeValueIndex = index;
80
- };
81
- var attributeValues = [
82
- { uri: '1', value: { UrlPreview: [{ value: '#0', uri: '01' }], UrlThumbnail: [{ value: '#00', uri: '11' }] } },
83
- { uri: '2', value: { UrlPreview: [{ value: '#1', uri: '02' }], UrlThumbnail: [{ value: '#01', uri: '12' }] } },
84
- { uri: '3', value: { UrlPreview: [{ value: '#2', uri: '03' }], UrlThumbnail: [{ value: '#02', uri: '13' }] } },
85
- { uri: '4', value: { UrlPreview: [{ value: '#3', uri: '04' }], UrlThumbnail: [{ value: '#03', uri: '14' }] } },
86
- { uri: '5', value: { UrlPreview: [{ value: '#4', uri: '05' }], UrlThumbnail: [{ value: '#04', uri: '15' }] } }
87
- ];
88
- var props = { attributeValueIndex: attributeValueIndex, setAttributeValueIndex: setAttributeValueIndex, attributeValues: attributeValues };
89
- var component = mount(React.createElement(ImageDetailsViewCarousel, __assign({}, props)));
90
- var images = component.find(Image);
91
- expect(images.filter('.thumb').length).toBe(5);
92
- expect(images.filter('.mainImage').prop('src')).toBe('#3');
93
- var thumbGrid = images.filter('.thumb[src="#00"]').find('img');
94
- thumbGrid.simulate('click');
95
- component.setProps(__assign(__assign({}, props), { attributeValueIndex: attributeValueIndex }));
96
- component.update();
97
- expect(component.find(Image).filter('.mainImage').prop('src')).toBe('#0');
98
- });
99
- });