@enact/ui 4.1.1 → 4.1.4

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 (92) hide show
  1. package/AnnounceDecorator/tests/Announce-specs.js +13 -5
  2. package/AnnounceDecorator/tests/AnnounceDecorator-specs.js +9 -7
  3. package/AnnounceDecorator/tests/useAnnounce-specs.js +25 -17
  4. package/BodyText/BodyText.d.ts +1 -1
  5. package/BodyText/tests/BodyText-specs.js +49 -35
  6. package/Button/Button.d.ts +6 -6
  7. package/Button/Button.js +5 -3
  8. package/Button/tests/Button-specs.js +104 -3
  9. package/CHANGELOG.md +26 -0
  10. package/Cancelable/Cancelable.js +1 -1
  11. package/Cancelable/tests/Cancelable-specs.js +131 -70
  12. package/Changeable/tests/Changeable-specs.js +162 -110
  13. package/FloatingLayer/FloatingLayer.js +5 -17
  14. package/FloatingLayer/tests/FloatingLayer-specs.js +83 -8
  15. package/FloatingLayer/tests/Scrim-specs.js +20 -11
  16. package/FloatingLayer/tests/useFloatingLayerDecorator-specs.js +15 -9
  17. package/GridListImageItem/GridListImageItem.d.ts +1 -1
  18. package/Group/Group.d.ts +2 -2
  19. package/Group/tests/Group-specs.js +71 -41
  20. package/Heading/Heading.d.ts +2 -1
  21. package/Heading/tests/Heading-specs.js +27 -20
  22. package/Icon/Icon.d.ts +4 -4
  23. package/Icon/tests/Icon-specs.js +52 -31
  24. package/IconButton/IconButton.d.ts +4 -4
  25. package/IconButton/tests/IconButton-specs.js +2 -2
  26. package/Image/tests/Image-specs.js +39 -29
  27. package/ImageItem/tests/ImageItem-specs.js +71 -68
  28. package/Item/tests/Item-specs.js +59 -35
  29. package/LabeledIcon/LabeledIcon.d.ts +4 -4
  30. package/LabeledIcon/tests/LabeledIcon-specs.js +30 -19
  31. package/Layout/Layout.d.ts +16 -16
  32. package/Layout/tests/Layout-specs.js +37 -25
  33. package/Marquee/MarqueeBase.js +1 -5
  34. package/Marquee/MarqueeDecorator.js +6 -3
  35. package/Marquee/index.d.ts +4 -1
  36. package/Marquee/tests/Marquee-specs.js +242 -116
  37. package/Media/Media.js +1 -3
  38. package/ProgressBar/tests/ProgressBar-specs.js +60 -42
  39. package/README.md +1 -1
  40. package/RadioDecorator/RadioDecorator.js +3 -5
  41. package/RadioDecorator/tests/RadioDecorator-specs.js +179 -65
  42. package/Repeater/Repeater.d.ts +2 -1
  43. package/Repeater/tests/Repeater-specs.js +86 -45
  44. package/Routable/Routable.d.ts +2 -2
  45. package/Routable/tests/Routable-specs.js +26 -17
  46. package/Routable/tests/Router-specs.js +65 -41
  47. package/Scrollable/Scrollable.js +2 -1
  48. package/Scrollable/ScrollableNative.js +2 -1
  49. package/Scroller/Scroller.d.ts +2 -14
  50. package/Scroller/ScrollerBasic.js +10 -29
  51. package/Scroller/UiScrollerBase.js +1 -1
  52. package/Skinnable/tests/Skinnable-specs.js +102 -54
  53. package/Skinnable/tests/useSkins-specs.js +37 -42
  54. package/Slider/Slider.d.ts +3 -3
  55. package/Slider/tests/Slider-specs.js +4 -4
  56. package/SlotItem/SlotItem.d.ts +2 -2
  57. package/SlotItem/tests/SlotItem-specs.js +4 -4
  58. package/Slottable/tests/Slottable-specs.js +67 -36
  59. package/Slottable/tests/useSlots-specs.js +68 -35
  60. package/Spinner/Spinner.d.ts +1 -1
  61. package/Spinner/tests/Spinner-specs.js +46 -31
  62. package/ToggleIcon/tests/ToggleIcon-specs.js +32 -20
  63. package/ToggleItem/ToggleItem.d.ts +13 -11
  64. package/ToggleItem/tests/ToggleItem-specs.js +51 -34
  65. package/Toggleable/Toggle.js +6 -6
  66. package/Toggleable/Toggleable.js +6 -12
  67. package/Toggleable/tests/Toggleable-specs.js +428 -324
  68. package/Touchable/Drag.js +13 -17
  69. package/Touchable/Flick.js +20 -16
  70. package/Touchable/Hold.js +14 -19
  71. package/Touchable/Touchable.d.ts +3 -3
  72. package/Touchable/tests/Touchable-specs.js +223 -109
  73. package/Touchable/tests/useTouch-specs.js +159 -84
  74. package/Transition/Transition.d.ts +29 -27
  75. package/Transition/Transition.js +11 -9
  76. package/Transition/tests/Transition-specs.js +111 -31
  77. package/ViewManager/TransitionGroup.js +6 -5
  78. package/ViewManager/View.js +1 -1
  79. package/ViewManager/ViewManager.d.ts +4 -4
  80. package/ViewManager/ViewManager.js +10 -10
  81. package/ViewManager/tests/View-specs.js +109 -81
  82. package/ViewManager/tests/ViewManager-specs.js +471 -185
  83. package/VirtualList/UiVirtualListBase.js +11 -21
  84. package/VirtualList/VirtualList.d.ts +11 -29
  85. package/VirtualList/VirtualListBasic.js +33 -49
  86. package/VirtualList/tests/VirtualList-specs.js +29 -61
  87. package/internal/IdProvider/tests/useId-specs.js +35 -18
  88. package/package.json +11 -11
  89. package/resolution/tests/ResolutionDecorator-specs.js +17 -8
  90. package/styles/mixins.less +14 -2
  91. package/useControlledState/tests/useControlledState-specs.js +67 -42
  92. package/useScroll/useScroll.js +12 -26
@@ -93,7 +93,7 @@ var ScrollerBasic = /*#__PURE__*/function (_Component) {
93
93
 
94
94
  _this.getRtlPositionX = function (x) {
95
95
  if (_this.props.rtl) {
96
- return _platform.platform.ios || _platform.platform.safari || _platform.platform.chrome >= 85 ? -x : _this.scrollBounds.maxLeft - x;
96
+ return _platform.platform.ios || _platform.platform.safari || _platform.platform.chrome >= 85 || _platform.platform.androidChrome >= 85 ? -x : _this.scrollBounds.maxLeft - x;
97
97
  }
98
98
 
99
99
  return x;
@@ -170,7 +170,8 @@ var ScrollerBasic = /*#__PURE__*/function (_Component) {
170
170
  }
171
171
  }, {
172
172
  key: "setScrollPosition",
173
- value: function setScrollPosition(x, y) {
173
+ value: // scrollMode 'translate'
174
+ function setScrollPosition(x, y) {
174
175
  var node = this.props.scrollContentRef.current;
175
176
 
176
177
  if (this.isVertical()) {
@@ -182,12 +183,16 @@ var ScrollerBasic = /*#__PURE__*/function (_Component) {
182
183
  node.scrollLeft = this.getRtlPositionX(x);
183
184
  this.scrollPos.left = x;
184
185
  }
185
- } // scrollMode 'translate'
186
+ } // scrollMode 'native'
186
187
 
187
188
  }, {
188
189
  key: "scrollToPosition",
189
- value: function scrollToPosition(x, y) {
190
- this.props.scrollContentRef.current.scrollTo(this.getRtlPositionX(x), y);
190
+ value: function scrollToPosition(left, top, behavior) {
191
+ this.props.scrollContentRef.current.scrollTo({
192
+ left: this.getRtlPositionX(left),
193
+ top: top,
194
+ behavior: behavior
195
+ });
191
196
  } // scrollMode 'native'
192
197
 
193
198
  }, {
@@ -260,30 +265,6 @@ ScrollerBasic.propTypes =
260
265
  */
261
266
  cbScrollTo: _propTypes2["default"].func,
262
267
 
263
- /**
264
- * Disable voice control feature of component.
265
- *
266
- * @type {Boolean}
267
- * @public
268
- */
269
- 'data-webos-voice-disabled': _propTypes2["default"].bool,
270
-
271
- /**
272
- * Activates the component for voice control.
273
- *
274
- * @type {Boolean}
275
- * @public
276
- */
277
- 'data-webos-voice-focused': _propTypes2["default"].bool,
278
-
279
- /**
280
- * The voice control group label.
281
- *
282
- * @type {String}
283
- * @public
284
- */
285
- 'data-webos-voice-group-label': _propTypes2["default"].string,
286
-
287
268
  /**
288
269
  * Direction of the scroller.
289
270
  *
@@ -89,7 +89,7 @@ var ScrollerBase = /*#__PURE__*/function (_Component) {
89
89
 
90
90
  _this.getRtlPositionX = function (x) {
91
91
  if (_this.props.rtl) {
92
- return _platform.platform.ios || _platform.platform.safari || _platform.platform.chrome >= 85 ? -x : _this.scrollBounds.maxLeft - x;
92
+ return _platform.platform.ios || _platform.platform.safari || _platform.platform.chrome >= 85 || _platform.platform.androidChrome >= 85 ? -x : _this.scrollBounds.maxLeft - x;
93
93
  }
94
94
 
95
95
  return x;
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
 
3
- var _enzyme = require("enzyme");
3
+ require("@testing-library/jest-dom");
4
+
5
+ var _react = require("@testing-library/react");
4
6
 
5
7
  var _Skinnable = _interopRequireDefault(require("../Skinnable"));
6
8
 
@@ -17,16 +19,16 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
17
19
  describe('Skinnable Specs', function () {
18
20
  test('should do nothing when nothing is specified', function () {
19
21
  var config = {};
22
+ var data;
20
23
 
21
24
  var Component = function Component(props) {
25
+ data = props;
22
26
  return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", _objectSpread({}, props));
23
27
  };
24
28
 
25
29
  var SkinnableComponent = (0, _Skinnable["default"])(config, Component);
26
- var subject = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(SkinnableComponent, {}));
27
- var expected = 0;
28
- var actual = Object.keys(subject.find('div').props()).length;
29
- expect(actual).toEqual(expected);
30
+ (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(SkinnableComponent, {}));
31
+ expect(data).toMatchObject({});
30
32
  });
31
33
  test('should add a default skin class when no skin prop is specified', function () {
32
34
  var config = {
@@ -42,10 +44,14 @@ describe('Skinnable Specs', function () {
42
44
  };
43
45
 
44
46
  var SkinnableComponent = (0, _Skinnable["default"])(config, Component);
45
- var subject = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(SkinnableComponent, {}));
47
+ (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(SkinnableComponent, {
48
+ "data-testid": "skinnableComponent"
49
+ }));
46
50
  var expected = 'darkSkin';
47
- var actual = subject.find('div').prop('className');
48
- expect(actual).toEqual(expected);
51
+
52
+ var component = _react.screen.getByTestId('skinnableComponent');
53
+
54
+ expect(component).toHaveClass(expected);
49
55
  });
50
56
  test('should add the preferred skin class when the skin prop is specified', function () {
51
57
  var config = {
@@ -61,12 +67,15 @@ describe('Skinnable Specs', function () {
61
67
  };
62
68
 
63
69
  var SkinnableComponent = (0, _Skinnable["default"])(config, Component);
64
- var subject = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(SkinnableComponent, {
70
+ (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(SkinnableComponent, {
71
+ "data-testid": "skinnableComponent",
65
72
  skin: "light"
66
73
  }));
67
74
  var expected = 'lightSkin';
68
- var actual = subject.find('div').prop('className');
69
- expect(actual).toEqual(expected);
75
+
76
+ var component = _react.screen.getByTestId('skinnableComponent');
77
+
78
+ expect(component).toHaveClass(expected);
70
79
  });
71
80
  test('should ignore the preferred skin prop if it\'s not one of the available skins', function () {
72
81
  var config = {
@@ -76,18 +85,19 @@ describe('Skinnable Specs', function () {
76
85
  light: 'lightSkin'
77
86
  }
78
87
  };
88
+ var data;
79
89
 
80
90
  var Component = function Component(props) {
91
+ data = props;
81
92
  return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", _objectSpread({}, props));
82
93
  };
83
94
 
84
95
  var SkinnableComponent = (0, _Skinnable["default"])(config, Component);
85
- var subject = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(SkinnableComponent, {
96
+ (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(SkinnableComponent, {
97
+ "data-testid": "skinnableComponent",
86
98
  skin: "potato"
87
99
  }));
88
- var expected = void 0;
89
- var actual = subject.find('div').prop('className');
90
- expect(actual).toEqual(expected);
100
+ expect(data).toMatchObject({});
91
101
  });
92
102
  test('should ignore the preferred skin prop if it\'s not one of the available skins and not interfere with the className prop', function () {
93
103
  var config = {
@@ -103,13 +113,16 @@ describe('Skinnable Specs', function () {
103
113
  };
104
114
 
105
115
  var SkinnableComponent = (0, _Skinnable["default"])(config, Component);
106
- var subject = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(SkinnableComponent, {
107
- skin: "potato",
108
- className: "cheatingComponent"
116
+ (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(SkinnableComponent, {
117
+ className: "cheatingComponent",
118
+ "data-testid": "skinnableComponent",
119
+ skin: "potato"
109
120
  }));
110
121
  var expected = 'cheatingComponent';
111
- var actual = subject.find('div').prop('className');
112
- expect(actual).toEqual(expected);
122
+
123
+ var component = _react.screen.getByTestId('skinnableComponent');
124
+
125
+ expect(component).toHaveClass(expected);
113
126
  });
114
127
  test('should ignore the skinVariants prop if there are no defined allowedVariants', function () {
115
128
  var config = {
@@ -125,12 +138,15 @@ describe('Skinnable Specs', function () {
125
138
  };
126
139
 
127
140
  var SkinnableComponent = (0, _Skinnable["default"])(config, Component);
128
- var subject = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(SkinnableComponent, {
141
+ (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(SkinnableComponent, {
142
+ "data-testid": "skinnableComponent",
129
143
  skinVariants: "potato"
130
144
  }));
131
145
  var expected = 'darkSkin';
132
- var actual = subject.find('div').prop('className');
133
- expect(actual).toEqual(expected);
146
+
147
+ var component = _react.screen.getByTestId('skinnableComponent');
148
+
149
+ expect(component).toHaveClass(expected);
134
150
  });
135
151
  test('should only apply allowed variants assigned by the skinVariants prop', function () {
136
152
  var config = {
@@ -147,12 +163,15 @@ describe('Skinnable Specs', function () {
147
163
  };
148
164
 
149
165
  var SkinnableComponent = (0, _Skinnable["default"])(config, Component);
150
- var subject = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(SkinnableComponent, {
166
+ (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(SkinnableComponent, {
167
+ "data-testid": "skinnableComponent",
151
168
  skinVariants: "normal potato unicase"
152
169
  }));
153
170
  var expected = 'darkSkin normal unicase';
154
- var actual = subject.find('div').prop('className');
155
- expect(actual).toEqual(expected);
171
+
172
+ var component = _react.screen.getByTestId('skinnableComponent');
173
+
174
+ expect(component).toHaveClass(expected);
156
175
  });
157
176
  test('should apply default variants even if the skinVariants prop is explicitly empty', function () {
158
177
  var config = {
@@ -170,12 +189,15 @@ describe('Skinnable Specs', function () {
170
189
  };
171
190
 
172
191
  var SkinnableComponent = (0, _Skinnable["default"])(config, Component);
173
- var subject = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(SkinnableComponent, {
192
+ (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(SkinnableComponent, {
193
+ "data-testid": "skinnableComponent",
174
194
  skinVariants: ""
175
195
  }));
176
196
  var expected = 'darkSkin normal';
177
- var actual = subject.find('div').prop('className');
178
- expect(actual).toEqual(expected);
197
+
198
+ var component = _react.screen.getByTestId('skinnableComponent');
199
+
200
+ expect(component).toHaveClass(expected);
179
201
  });
180
202
  test('should apply default variants and the skinVariants if both are defined', function () {
181
203
  var config = {
@@ -193,12 +215,15 @@ describe('Skinnable Specs', function () {
193
215
  };
194
216
 
195
217
  var SkinnableComponent = (0, _Skinnable["default"])(config, Component);
196
- var subject = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(SkinnableComponent, {
218
+ (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(SkinnableComponent, {
219
+ "data-testid": "skinnableComponent",
197
220
  skinVariants: "unicase"
198
221
  }));
199
222
  var expected = 'darkSkin normal unicase';
200
- var actual = subject.find('div').prop('className');
201
- expect(actual).toEqual(expected);
223
+
224
+ var component = _react.screen.getByTestId('skinnableComponent');
225
+
226
+ expect(component).toHaveClass(expected);
202
227
  });
203
228
  test('should apply variants supplied via an array or a string in the same way', function () {
204
229
  var config = {
@@ -216,13 +241,21 @@ describe('Skinnable Specs', function () {
216
241
  };
217
242
 
218
243
  var SkinnableComponent = (0, _Skinnable["default"])(config, Component);
219
- var subjectA = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(SkinnableComponent, {
244
+ (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(SkinnableComponent, {
245
+ "data-testid": "skinnableComponent1",
220
246
  skinVariants: "normal unicase"
221
247
  }));
222
- var subjectB = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(SkinnableComponent, {
248
+
249
+ var component1ClassNames = _react.screen.getByTestId('skinnableComponent1').className;
250
+
251
+ (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(SkinnableComponent, {
252
+ "data-testid": "skinnableComponent2",
223
253
  skinVariants: ['normal', 'unicase']
224
254
  }));
225
- expect(subjectA.find('div')).toEqual(subjectB.find('div'));
255
+
256
+ var component2ClassNames = _react.screen.getByTestId('skinnableComponent2').className;
257
+
258
+ expect(component1ClassNames).toEqual(component2ClassNames);
226
259
  });
227
260
  test('should allow opting out of the default variants if an object is supplied to skinVariants with false as variant-key values', function () {
228
261
  var config = {
@@ -240,15 +273,18 @@ describe('Skinnable Specs', function () {
240
273
  };
241
274
 
242
275
  var SkinnableComponent = (0, _Skinnable["default"])(config, Component);
243
- var subject = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(SkinnableComponent, {
276
+ (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(SkinnableComponent, {
277
+ "data-testid": "skinnableComponent",
244
278
  skinVariants: {
245
279
  normal: false,
246
280
  unicase: true
247
281
  }
248
282
  }));
249
283
  var expected = 'darkSkin unicase';
250
- var actual = subject.find('div').prop('className');
251
- expect(actual).toEqual(expected);
284
+
285
+ var component = _react.screen.getByTestId('skinnableComponent');
286
+
287
+ expect(component).toHaveClass(expected);
252
288
  });
253
289
  test('should ignore variants, sent by an object, equaling null, undefined, or empty string', function () {
254
290
  var config = {
@@ -266,7 +302,8 @@ describe('Skinnable Specs', function () {
266
302
  };
267
303
 
268
304
  var SkinnableComponent = (0, _Skinnable["default"])(config, Component);
269
- var subject = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(SkinnableComponent, {
305
+ (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(SkinnableComponent, {
306
+ "data-testid": "skinnableComponent",
270
307
  skinVariants: {
271
308
  normal: null,
272
309
  smallCaps: void 0,
@@ -274,8 +311,10 @@ describe('Skinnable Specs', function () {
274
311
  }
275
312
  }));
276
313
  var expected = 'darkSkin normal';
277
- var actual = subject.find('div').prop('className');
278
- expect(actual).toEqual(expected);
314
+
315
+ var component = _react.screen.getByTestId('skinnableComponent');
316
+
317
+ expect(component).toHaveClass(expected);
279
318
  });
280
319
  test('should apply parent variants', function () {
281
320
  var config = {
@@ -294,15 +333,18 @@ describe('Skinnable Specs', function () {
294
333
 
295
334
  var SkinnableParent = (0, _Skinnable["default"])(config, Component);
296
335
  var SkinnableChild = (0, _Skinnable["default"])(config, Component);
297
- var subject = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(SkinnableParent, {
336
+ (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(SkinnableParent, {
298
337
  skinVariants: "unicase",
299
338
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(SkinnableChild, {
339
+ "data-testid": "skinnableChild",
300
340
  skinVariants: "smallCaps"
301
341
  })
302
342
  }));
303
343
  var expected = 'darkSkin normal unicase smallCaps';
304
- var actual = subject.find('div').last().prop('className');
305
- expect(actual).toEqual(expected);
344
+
345
+ var component = _react.screen.getByTestId('skinnableChild');
346
+
347
+ expect(component).toHaveClass(expected);
306
348
  });
307
349
  test('should be able to override a parent\'s variants by assigning a false skinVariant', function () {
308
350
  var config = {
@@ -321,17 +363,20 @@ describe('Skinnable Specs', function () {
321
363
 
322
364
  var SkinnableParent = (0, _Skinnable["default"])(config, Component);
323
365
  var SkinnableChild = (0, _Skinnable["default"])(config, Component);
324
- var subject = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(SkinnableParent, {
366
+ (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(SkinnableParent, {
325
367
  skinVariants: "smallCaps unicase",
326
368
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(SkinnableChild, {
369
+ "data-testid": "skinnableChild",
327
370
  skinVariants: {
328
371
  unicase: false
329
372
  }
330
373
  })
331
374
  }));
332
375
  var expected = 'darkSkin normal smallCaps';
333
- var actual = subject.find('div').last().prop('className');
334
- expect(actual).toEqual(expected);
376
+
377
+ var component = _react.screen.getByTestId('skinnableChild');
378
+
379
+ expect(component).toHaveClass(expected);
335
380
  });
336
381
  test('should inherit an overridden default variant', function () {
337
382
  var config = {
@@ -350,21 +395,23 @@ describe('Skinnable Specs', function () {
350
395
 
351
396
  var SkinnableParent = (0, _Skinnable["default"])(config, Component);
352
397
  var SkinnableChild = (0, _Skinnable["default"])(config, Component);
353
- var subject = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(SkinnableParent, {
398
+ (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(SkinnableParent, {
354
399
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(SkinnableChild, {
355
400
  skinVariants: {
356
401
  normal: false
357
402
  },
358
403
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(SkinnableChild, {
359
- id: "innerChild"
404
+ "data-testid": "innerChild"
360
405
  })
361
406
  })
362
407
  }));
363
408
  var expected = 'darkSkin';
364
- var actual = subject.find('div#innerChild').prop('className');
365
- expect(actual).toEqual(expected);
409
+
410
+ var component = _react.screen.getByTestId('innerChild');
411
+
412
+ expect(component).toHaveClass(expected);
366
413
  });
367
- test('should not force re-render of child if child unaffected', function () {
414
+ test.skip('should not force re-render of child if child unaffected', function () {
368
415
  var config = {
369
416
  defaultSkin: 'dark',
370
417
  defaultVariants: 'normal',
@@ -388,8 +435,9 @@ describe('Skinnable Specs', function () {
388
435
  };
389
436
 
390
437
  var SkinnableParent = (0, _Skinnable["default"])(config, Component);
391
- var SkinnableChild = (0, _Skinnable["default"])(config, ChildComponent);
392
- var subject = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(SkinnableParent, {
438
+ var SkinnableChild = (0, _Skinnable["default"])(config, ChildComponent); // eslint-disable-next-line
439
+
440
+ var subject = mount( /*#__PURE__*/(0, _jsxRuntime.jsx)(SkinnableParent, {
393
441
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(SkinnableChild, {})
394
442
  })); // Sending props to force parent to re-render
395
443
 
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
 
3
- var _enzyme = require("enzyme");
3
+ require("@testing-library/jest-dom");
4
+
5
+ var _react = require("@testing-library/react");
4
6
 
5
7
  var _useSkins = _interopRequireDefault(require("../useSkins"));
6
8
 
@@ -15,9 +17,12 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
15
17
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
16
18
 
17
19
  describe('Skinnable Specs', function () {
18
- function Base() {
20
+ var data;
21
+
22
+ var Base = function Base(props) {
23
+ data = props;
19
24
  return null;
20
- }
25
+ };
21
26
 
22
27
  function Component(_ref) {
23
28
  var config = _ref.config;
@@ -40,12 +45,11 @@ describe('Skinnable Specs', function () {
40
45
  light: 'lightSkin'
41
46
  }
42
47
  };
43
- var subject = (0, _enzyme.shallow)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
48
+ (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
44
49
  config: config
45
50
  }));
46
51
  var expected = 'darkSkin';
47
- var actual = subject.find(Base).prop('className');
48
- expect(actual).toBe(expected);
52
+ expect(data).toHaveProperty('className', expected);
49
53
  });
50
54
  test('should add the preferred skin class when the skin prop is specified', function () {
51
55
  var config = {
@@ -56,12 +60,11 @@ describe('Skinnable Specs', function () {
56
60
  light: 'lightSkin'
57
61
  }
58
62
  };
59
- var subject = (0, _enzyme.shallow)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
63
+ (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
60
64
  config: config
61
65
  }));
62
66
  var expected = 'lightSkin';
63
- var actual = subject.find(Base).prop('className');
64
- expect(actual).toBe(expected);
67
+ expect(data).toHaveProperty('className', expected);
65
68
  });
66
69
  test('should ignore the preferred skin prop if it\'s not one of the available skins', function () {
67
70
  var config = {
@@ -72,12 +75,11 @@ describe('Skinnable Specs', function () {
72
75
  light: 'lightSkin'
73
76
  }
74
77
  };
75
- var subject = (0, _enzyme.shallow)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
78
+ (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
76
79
  config: config
77
80
  }));
78
81
  var expected = '';
79
- var actual = subject.find(Base).prop('className');
80
- expect(actual).toBe(expected);
82
+ expect(data).toHaveProperty('className', expected);
81
83
  });
82
84
  test('should ignore the skinVariants prop if there are no defined allowedVariants', function () {
83
85
  var config = {
@@ -88,12 +90,11 @@ describe('Skinnable Specs', function () {
88
90
  light: 'lightSkin'
89
91
  }
90
92
  };
91
- var subject = (0, _enzyme.shallow)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
93
+ (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
92
94
  config: config
93
95
  }));
94
96
  var expected = 'darkSkin';
95
- var actual = subject.find(Base).prop('className');
96
- expect(actual).toBe(expected);
97
+ expect(data).toHaveProperty('className', expected);
97
98
  });
98
99
  test('should only apply allowed variants assigned by the skinVariants prop', function () {
99
100
  var config = {
@@ -105,12 +106,11 @@ describe('Skinnable Specs', function () {
105
106
  },
106
107
  variants: ['normal', 'smallCaps', 'unicase']
107
108
  };
108
- var subject = (0, _enzyme.shallow)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
109
+ (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
109
110
  config: config
110
111
  }));
111
112
  var expected = 'darkSkin normal unicase';
112
- var actual = subject.find(Base).prop('className');
113
- expect(actual).toBe(expected);
113
+ expect(data).toHaveProperty('className', expected);
114
114
  });
115
115
  test('should apply default variants even if the skinVariants prop is explicitly empty', function () {
116
116
  var config = {
@@ -123,12 +123,11 @@ describe('Skinnable Specs', function () {
123
123
  },
124
124
  variants: ['normal', 'smallCaps', 'unicase']
125
125
  };
126
- var subject = (0, _enzyme.shallow)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
126
+ (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
127
127
  config: config
128
128
  }));
129
129
  var expected = 'darkSkin normal';
130
- var actual = subject.find(Base).prop('className');
131
- expect(actual).toBe(expected);
130
+ expect(data).toHaveProperty('className', expected);
132
131
  });
133
132
  test('should apply default variants and the skinVariants if both are defined', function () {
134
133
  var config = {
@@ -141,12 +140,11 @@ describe('Skinnable Specs', function () {
141
140
  },
142
141
  variants: ['normal', 'smallCaps', 'unicase']
143
142
  };
144
- var subject = (0, _enzyme.shallow)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
143
+ (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
145
144
  config: config
146
145
  }));
147
146
  var expected = 'darkSkin normal unicase';
148
- var actual = subject.find(Base).prop('className');
149
- expect(actual).toBe(expected);
147
+ expect(data).toHaveProperty('className', expected);
150
148
  });
151
149
  test('should apply variants supplied via an array or a string in the same way', function () {
152
150
  var config = {
@@ -158,17 +156,19 @@ describe('Skinnable Specs', function () {
158
156
  },
159
157
  variants: ['normal', 'smallCaps', 'unicase']
160
158
  };
161
- var subjectA = (0, _enzyme.shallow)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
159
+ (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
162
160
  config: _objectSpread(_objectSpread({}, config), {}, {
163
161
  skinVariants: 'normal unicase'
164
162
  })
165
163
  }));
166
- var subjectB = (0, _enzyme.shallow)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
164
+ var component1Class = data.className;
165
+ (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
167
166
  config: _objectSpread(_objectSpread({}, config), {}, {
168
167
  skinVariants: ['normal', 'unicase']
169
168
  })
170
169
  }));
171
- expect(subjectA.find(Base).prop('className')).toBe(subjectB.find(Base).prop('className'));
170
+ var component2Class = data.className;
171
+ expect(component1Class).toBe(component2Class);
172
172
  });
173
173
  test('should allow opting out of the default variants if an object is supplied to skinVariants with false as variant-key values', function () {
174
174
  var config = {
@@ -184,12 +184,11 @@ describe('Skinnable Specs', function () {
184
184
  },
185
185
  variants: ['normal', 'smallCaps', 'unicase']
186
186
  };
187
- var subject = (0, _enzyme.shallow)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
187
+ (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
188
188
  config: config
189
189
  }));
190
190
  var expected = 'darkSkin unicase';
191
- var actual = subject.find(Base).prop('className');
192
- expect(actual).toBe(expected);
191
+ expect(data).toHaveProperty('className', expected);
193
192
  });
194
193
  test('should ignore variants, sent by an object, equaling null, undefined, or empty string', function () {
195
194
  var config = {
@@ -206,12 +205,11 @@ describe('Skinnable Specs', function () {
206
205
  },
207
206
  variants: ['normal', 'smallCaps', 'unicase']
208
207
  };
209
- var subject = (0, _enzyme.shallow)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
208
+ (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
210
209
  config: config
211
210
  }));
212
211
  var expected = 'darkSkin normal';
213
- var actual = subject.find(Base).prop('className');
214
- expect(actual).toBe(expected);
212
+ expect(data).toHaveProperty('className', expected);
215
213
  });
216
214
  test('should apply parent variants', function () {
217
215
  var config = {
@@ -223,7 +221,7 @@ describe('Skinnable Specs', function () {
223
221
  },
224
222
  variants: ['normal', 'smallCaps', 'unicase']
225
223
  };
226
- var subject = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Parent, {
224
+ (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Parent, {
227
225
  config: _objectSpread(_objectSpread({}, config), {}, {
228
226
  skinVariants: 'unicase'
229
227
  }),
@@ -234,8 +232,7 @@ describe('Skinnable Specs', function () {
234
232
  })
235
233
  }));
236
234
  var expected = 'darkSkin normal unicase smallCaps';
237
- var actual = subject.find(Base).prop('className');
238
- expect(actual).toBe(expected);
235
+ expect(data).toHaveProperty('className', expected);
239
236
  });
240
237
  test('should be able to override a parent\'s variants by assigning a false skinVariant', function () {
241
238
  var config = {
@@ -247,7 +244,7 @@ describe('Skinnable Specs', function () {
247
244
  },
248
245
  variants: ['normal', 'smallCaps', 'unicase']
249
246
  };
250
- var subject = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Parent, {
247
+ (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Parent, {
251
248
  config: _objectSpread(_objectSpread({}, config), {}, {
252
249
  skinVariants: 'smallCaps unicase'
253
250
  }),
@@ -260,8 +257,7 @@ describe('Skinnable Specs', function () {
260
257
  })
261
258
  }));
262
259
  var expected = 'darkSkin normal smallCaps';
263
- var actual = subject.find(Base).prop('className');
264
- expect(actual).toBe(expected);
260
+ expect(data).toHaveProperty('className', expected);
265
261
  });
266
262
  test('should inherit an overridden default variant', function () {
267
263
  var config = {
@@ -273,7 +269,7 @@ describe('Skinnable Specs', function () {
273
269
  },
274
270
  variants: ['normal', 'smallCaps', 'unicase']
275
271
  };
276
- var subject = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Parent, {
272
+ (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Parent, {
277
273
  config: config,
278
274
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(Parent, {
279
275
  config: _objectSpread(_objectSpread({}, config), {}, {
@@ -287,7 +283,6 @@ describe('Skinnable Specs', function () {
287
283
  })
288
284
  }));
289
285
  var expected = 'darkSkin';
290
- var actual = subject.find(Base).prop('className');
291
- expect(actual).toBe(expected);
286
+ expect(data).toHaveProperty('className', expected);
292
287
  });
293
288
  });