@enact/ui 4.1.2 → 4.1.3
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/AnnounceDecorator/tests/Announce-specs.js +13 -5
- package/AnnounceDecorator/tests/AnnounceDecorator-specs.js +9 -7
- package/AnnounceDecorator/tests/useAnnounce-specs.js +25 -17
- package/BodyText/BodyText.d.ts +1 -1
- package/BodyText/tests/BodyText-specs.js +49 -35
- package/Button/Button.d.ts +6 -6
- package/Button/tests/Button-specs.js +104 -3
- package/CHANGELOG.md +4 -0
- package/Cancelable/Cancelable.js +1 -1
- package/Cancelable/tests/Cancelable-specs.js +131 -70
- package/Changeable/tests/Changeable-specs.js +162 -110
- package/FloatingLayer/FloatingLayer.js +5 -17
- package/FloatingLayer/tests/FloatingLayer-specs.js +83 -8
- package/FloatingLayer/tests/Scrim-specs.js +20 -11
- package/FloatingLayer/tests/useFloatingLayerDecorator-specs.js +15 -9
- package/GridListImageItem/GridListImageItem.d.ts +1 -1
- package/Group/Group.d.ts +2 -2
- package/Group/tests/Group-specs.js +71 -41
- package/Heading/Heading.d.ts +2 -1
- package/Heading/tests/Heading-specs.js +27 -20
- package/Icon/Icon.d.ts +4 -4
- package/Icon/tests/Icon-specs.js +52 -31
- package/IconButton/IconButton.d.ts +4 -4
- package/IconButton/tests/IconButton-specs.js +2 -2
- package/Image/tests/Image-specs.js +39 -29
- package/ImageItem/tests/ImageItem-specs.js +71 -68
- package/Item/tests/Item-specs.js +59 -35
- package/LabeledIcon/LabeledIcon.d.ts +4 -4
- package/LabeledIcon/tests/LabeledIcon-specs.js +30 -19
- package/Layout/Layout.d.ts +16 -16
- package/Layout/tests/Layout-specs.js +37 -25
- package/Marquee/MarqueeBase.js +1 -5
- package/Marquee/tests/Marquee-specs.js +221 -116
- package/Media/Media.js +1 -3
- package/ProgressBar/tests/ProgressBar-specs.js +60 -42
- package/README.md +1 -1
- package/RadioDecorator/RadioDecorator.js +3 -5
- package/RadioDecorator/tests/RadioDecorator-specs.js +179 -65
- package/Repeater/Repeater.d.ts +2 -1
- package/Repeater/tests/Repeater-specs.js +86 -45
- package/Routable/Routable.d.ts +2 -2
- package/Routable/tests/Routable-specs.js +26 -17
- package/Routable/tests/Router-specs.js +65 -41
- package/Scrollable/Scrollable.js +1 -0
- package/Scrollable/ScrollableNative.js +1 -0
- package/Scroller/Scroller.d.ts +2 -2
- package/Skinnable/tests/Skinnable-specs.js +102 -54
- package/Skinnable/tests/useSkins-specs.js +37 -42
- package/Slider/Slider.d.ts +3 -3
- package/Slider/tests/Slider-specs.js +4 -4
- package/SlotItem/SlotItem.d.ts +2 -2
- package/SlotItem/tests/SlotItem-specs.js +4 -4
- package/Slottable/tests/Slottable-specs.js +67 -36
- package/Slottable/tests/useSlots-specs.js +68 -35
- package/Spinner/Spinner.d.ts +1 -1
- package/Spinner/tests/Spinner-specs.js +46 -31
- package/ToggleIcon/tests/ToggleIcon-specs.js +32 -20
- package/ToggleItem/ToggleItem.d.ts +13 -11
- package/ToggleItem/tests/ToggleItem-specs.js +51 -34
- package/Toggleable/Toggle.js +6 -6
- package/Toggleable/Toggleable.js +6 -12
- package/Toggleable/tests/Toggleable-specs.js +428 -324
- package/Touchable/Drag.js +13 -17
- package/Touchable/Flick.js +20 -16
- package/Touchable/Hold.js +14 -19
- package/Touchable/Touchable.d.ts +3 -3
- package/Touchable/tests/Touchable-specs.js +223 -109
- package/Touchable/tests/useTouch-specs.js +159 -84
- package/Transition/Transition.d.ts +29 -27
- package/Transition/Transition.js +5 -9
- package/Transition/tests/Transition-specs.js +135 -31
- package/ViewManager/TransitionGroup.js +6 -5
- package/ViewManager/View.js +1 -1
- package/ViewManager/ViewManager.d.ts +4 -4
- package/ViewManager/ViewManager.js +10 -10
- package/ViewManager/tests/View-specs.js +109 -81
- package/ViewManager/tests/ViewManager-specs.js +471 -185
- package/VirtualList/VirtualList.d.ts +11 -9
- package/VirtualList/tests/VirtualList-specs.js +44 -31
- package/internal/IdProvider/tests/useId-specs.js +35 -18
- package/package.json +11 -11
- package/resolution/tests/ResolutionDecorator-specs.js +17 -8
- package/styles/mixins.less +14 -2
- package/useControlledState/tests/useControlledState-specs.js +67 -42
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
require("@testing-library/jest-dom");
|
|
4
|
+
|
|
5
|
+
var _react = require("@testing-library/react");
|
|
4
6
|
|
|
5
7
|
var _FloatingLayer = require("../FloatingLayer");
|
|
6
8
|
|
|
@@ -21,28 +23,32 @@ describe('FloatingLayer Specs', function () {
|
|
|
21
23
|
}
|
|
22
24
|
|
|
23
25
|
test('should not render if FloatingLayer is not open', function () {
|
|
24
|
-
|
|
26
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Root, {
|
|
25
27
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_FloatingLayer.FloatingLayerBase, {
|
|
28
|
+
"data-testid": "floatingLayer",
|
|
26
29
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("p", {
|
|
27
30
|
children: "Hi"
|
|
28
31
|
})
|
|
29
32
|
})
|
|
30
33
|
}));
|
|
31
|
-
|
|
32
|
-
var
|
|
33
|
-
|
|
34
|
+
|
|
35
|
+
var floatingLayerContainer = _react.screen.queryByTestId('floatingLayer');
|
|
36
|
+
|
|
37
|
+
expect(floatingLayerContainer).not.toBeInTheDocument();
|
|
34
38
|
});
|
|
35
39
|
test('should render if FloatingLayer is open', function () {
|
|
36
|
-
|
|
40
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Root, {
|
|
37
41
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_FloatingLayer.FloatingLayerBase, {
|
|
42
|
+
"data-testid": "floatingLayer",
|
|
38
43
|
open: true,
|
|
39
44
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("p", {
|
|
40
45
|
children: "Hi"
|
|
41
46
|
})
|
|
42
47
|
})
|
|
43
48
|
}));
|
|
44
|
-
|
|
45
|
-
var
|
|
46
|
-
|
|
49
|
+
|
|
50
|
+
var floatingLayerContainer = _react.screen.getByTestId('floatingLayer');
|
|
51
|
+
|
|
52
|
+
expect(floatingLayerContainer).toBeInTheDocument();
|
|
47
53
|
});
|
|
48
54
|
});
|
package/Group/Group.d.ts
CHANGED
|
@@ -69,9 +69,9 @@ as `componentRef` .
|
|
|
69
69
|
* Selection mode for the group
|
|
70
70
|
* * `single` - Allows for 0 or 1 item to be selected. The selected item may be deselected.
|
|
71
71
|
* * `radio` - Allows for 0 or 1 item to be selected. The selected item may only be
|
|
72
|
-
|
|
72
|
+
deselected by selecting another item.
|
|
73
73
|
* * `multiple` - Allows 0 to _n_ items to be selected. Each item may be selected or
|
|
74
|
-
|
|
74
|
+
deselected.
|
|
75
75
|
*/
|
|
76
76
|
select?: string;
|
|
77
77
|
/**
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
require("@testing-library/jest-dom");
|
|
4
|
+
|
|
5
|
+
var _react = require("@testing-library/react");
|
|
6
|
+
|
|
7
|
+
var _userEvent = _interopRequireDefault(require("@testing-library/user-event"));
|
|
4
8
|
|
|
5
9
|
var _Group = _interopRequireWildcard(require("../Group"));
|
|
6
10
|
|
|
@@ -10,57 +14,72 @@ function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return
|
|
|
10
14
|
|
|
11
15
|
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
12
16
|
|
|
17
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
18
|
+
|
|
13
19
|
describe('Group', function () {
|
|
14
20
|
var stringItems = ['One', 'Two', 'Three'];
|
|
15
21
|
test('should call handler with selected on select', function () {
|
|
16
22
|
var handleClick = jest.fn();
|
|
17
|
-
|
|
23
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Group.GroupBase, {
|
|
18
24
|
childComponent: "div",
|
|
19
25
|
onSelect: handleClick,
|
|
20
26
|
children: stringItems
|
|
21
27
|
}));
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
28
|
+
|
|
29
|
+
var selected = _react.screen.getByText('Two');
|
|
30
|
+
|
|
31
|
+
_userEvent["default"].click(selected);
|
|
32
|
+
|
|
33
|
+
var expected = 1;
|
|
25
34
|
var actual = handleClick.mock.calls[0][0].selected;
|
|
26
35
|
expect(actual).toBe(expected);
|
|
27
36
|
});
|
|
28
37
|
test('should call handler with data on select', function () {
|
|
29
38
|
var handleClick = jest.fn();
|
|
30
|
-
|
|
39
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Group.GroupBase, {
|
|
31
40
|
childComponent: "div",
|
|
32
41
|
onSelect: handleClick,
|
|
33
42
|
children: stringItems
|
|
34
43
|
}));
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
44
|
+
|
|
45
|
+
var selected = _react.screen.getByText('Two');
|
|
46
|
+
|
|
47
|
+
_userEvent["default"].click(selected);
|
|
48
|
+
|
|
49
|
+
var expected = stringItems[1];
|
|
38
50
|
var actual = handleClick.mock.calls[0][0].data;
|
|
39
51
|
expect(actual).toBe(expected);
|
|
40
52
|
});
|
|
41
53
|
test('should call handler with data on select stored in the key specified by `selectedEventProp`', function () {
|
|
42
54
|
var handleClick = jest.fn();
|
|
43
|
-
|
|
55
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Group.GroupBase, {
|
|
44
56
|
childComponent: "div",
|
|
45
57
|
onSelect: handleClick,
|
|
46
58
|
selectedEventProp: "value",
|
|
47
59
|
children: stringItems
|
|
48
60
|
}));
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
61
|
+
|
|
62
|
+
var selected = _react.screen.getByText('Two');
|
|
63
|
+
|
|
64
|
+
_userEvent["default"].click(selected);
|
|
65
|
+
|
|
66
|
+
var expected = stringItems[1];
|
|
52
67
|
var actual = handleClick.mock.calls[0][0].value;
|
|
53
68
|
expect(actual).toBe(expected);
|
|
54
69
|
});
|
|
55
70
|
test('should call handler on move when childSelect="onMouseMove"', function () {
|
|
56
71
|
var handleClick = jest.fn();
|
|
57
|
-
|
|
72
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Group.GroupBase, {
|
|
58
73
|
childComponent: "div",
|
|
59
74
|
childSelect: "onMouseMove",
|
|
60
75
|
onSelect: handleClick,
|
|
61
76
|
children: stringItems
|
|
62
77
|
}));
|
|
63
|
-
|
|
78
|
+
|
|
79
|
+
var selected = _react.screen.getByText('Two');
|
|
80
|
+
|
|
81
|
+
_react.fireEvent.mouseMove(selected);
|
|
82
|
+
|
|
64
83
|
var expected = 1;
|
|
65
84
|
var actual = handleClick.mock.calls.length;
|
|
66
85
|
expect(actual).toBe(expected);
|
|
@@ -68,80 +87,91 @@ describe('Group', function () {
|
|
|
68
87
|
test('should select the third item with selected=2', function () {
|
|
69
88
|
var selected = 2;
|
|
70
89
|
var handleClick = jest.fn();
|
|
71
|
-
|
|
90
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Group.GroupBase, {
|
|
72
91
|
childComponent: "div",
|
|
73
|
-
selected: selected,
|
|
74
92
|
onSelect: handleClick,
|
|
93
|
+
selected: selected,
|
|
75
94
|
children: stringItems
|
|
76
95
|
}));
|
|
77
|
-
var expected = true;
|
|
78
|
-
|
|
79
|
-
|
|
96
|
+
var expected = 'true';
|
|
97
|
+
|
|
98
|
+
var actual = _react.screen.getByText('Three');
|
|
99
|
+
|
|
100
|
+
expect(actual).toHaveAttribute('data-selected', expected);
|
|
80
101
|
});
|
|
81
102
|
test('should set {data-active} on the first item', function () {
|
|
82
103
|
var selected = 0;
|
|
83
104
|
var handleClick = jest.fn();
|
|
84
|
-
|
|
105
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Group.GroupBase, {
|
|
85
106
|
childComponent: "div",
|
|
107
|
+
onSelect: handleClick,
|
|
86
108
|
selected: selected,
|
|
87
109
|
selectedProp: "data-active",
|
|
88
|
-
onSelect: handleClick,
|
|
89
110
|
children: stringItems
|
|
90
111
|
}));
|
|
91
|
-
var expected = true;
|
|
92
|
-
|
|
93
|
-
|
|
112
|
+
var expected = 'true';
|
|
113
|
+
|
|
114
|
+
var actual = _react.screen.getByText('One');
|
|
115
|
+
|
|
116
|
+
expect(actual).toHaveAttribute('data-active', expected);
|
|
94
117
|
});
|
|
95
118
|
test('should set {children} to be the item by default', function () {
|
|
96
119
|
var selected = 0;
|
|
97
120
|
var handleClick = jest.fn();
|
|
98
|
-
|
|
121
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Group.GroupBase, {
|
|
99
122
|
childComponent: "div",
|
|
100
123
|
onSelect: handleClick,
|
|
101
124
|
children: stringItems
|
|
102
125
|
}));
|
|
103
126
|
var expected = stringItems[selected];
|
|
104
|
-
|
|
105
|
-
|
|
127
|
+
|
|
128
|
+
var actual = _react.screen.getByText('One');
|
|
129
|
+
|
|
130
|
+
expect(actual).toHaveTextContent(expected);
|
|
106
131
|
});
|
|
107
132
|
test('should set {data-child} to be the item', function () {
|
|
108
133
|
var selected = 0;
|
|
109
134
|
var handleClick = jest.fn();
|
|
110
|
-
|
|
135
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Group.GroupBase, {
|
|
111
136
|
childComponent: "div",
|
|
112
137
|
childProp: "data-child",
|
|
113
138
|
onSelect: handleClick,
|
|
114
139
|
children: stringItems
|
|
115
140
|
}));
|
|
116
141
|
var expected = stringItems[selected];
|
|
117
|
-
|
|
118
|
-
|
|
142
|
+
|
|
143
|
+
var actual = _react.screen.getByRole('group').firstChild;
|
|
144
|
+
|
|
145
|
+
expect(actual).toHaveAttribute('data-child', expected);
|
|
119
146
|
});
|
|
120
147
|
test('should set aria-multiselectable when select="multiple"', function () {
|
|
121
|
-
|
|
148
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Group.GroupBase, {
|
|
122
149
|
childComponent: "div",
|
|
123
150
|
select: "multiple",
|
|
124
151
|
children: stringItems
|
|
125
152
|
}));
|
|
126
|
-
var expected = true;
|
|
127
|
-
|
|
128
|
-
|
|
153
|
+
var expected = 'true';
|
|
154
|
+
|
|
155
|
+
var actual = _react.screen.getByRole('group');
|
|
156
|
+
|
|
157
|
+
expect(actual).toHaveAttribute('aria-multiselectable', expected);
|
|
129
158
|
});
|
|
130
159
|
test('should set role to group', function () {
|
|
131
|
-
|
|
160
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Group.GroupBase, {
|
|
132
161
|
childComponent: "div",
|
|
133
162
|
select: "multiple",
|
|
134
163
|
children: stringItems
|
|
135
164
|
}));
|
|
136
|
-
|
|
137
|
-
var actual =
|
|
138
|
-
|
|
165
|
+
|
|
166
|
+
var actual = _react.screen.getByRole('group');
|
|
167
|
+
|
|
168
|
+
expect(actual).toBeInTheDocument();
|
|
139
169
|
});
|
|
140
170
|
test('should return a DOM node reference for `componentRef`', function () {
|
|
141
171
|
var ref = jest.fn();
|
|
142
|
-
(0,
|
|
143
|
-
ref: ref,
|
|
172
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Group["default"], {
|
|
144
173
|
childComponent: "div",
|
|
174
|
+
ref: ref,
|
|
145
175
|
children: stringItems
|
|
146
176
|
}));
|
|
147
177
|
var expected = 'SPAN';
|
package/Heading/Heading.d.ts
CHANGED
|
@@ -50,7 +50,8 @@ corresponding internal elements and states of this component.
|
|
|
50
50
|
* Set the size of this component.
|
|
51
51
|
* * `'title'` and `'subtitle'` are generally considered to be used only once on a given screen.
|
|
52
52
|
* * `'large'` , `'medium'` , `'small'` , and `'tiny'` are typically used as section headings
|
|
53
|
-
|
|
53
|
+
*
|
|
54
|
+
* for content on a screen, starting with `'large'` for the first tier of information
|
|
54
55
|
followed by `'medium'` for the next, and so fourth.
|
|
55
56
|
*
|
|
56
57
|
* If the `spacing` prop is not set (defaulting to "auto"), these values automatically set
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
require("@testing-library/jest-dom");
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var _react = require("@testing-library/react");
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _Heading = _interopRequireDefault(require("../Heading"));
|
|
8
8
|
|
|
9
9
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
10
10
|
|
|
@@ -13,44 +13,51 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "d
|
|
|
13
13
|
describe('Heading Specs', function () {
|
|
14
14
|
test('should render a Heading with content', function () {
|
|
15
15
|
var content = 'Hello Heading!';
|
|
16
|
-
|
|
16
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Heading["default"], {
|
|
17
17
|
children: content
|
|
18
18
|
}));
|
|
19
|
-
|
|
20
|
-
var actual =
|
|
21
|
-
|
|
19
|
+
|
|
20
|
+
var actual = _react.screen.getByText('Hello Heading!');
|
|
21
|
+
|
|
22
|
+
expect(actual).toBeInTheDocument();
|
|
22
23
|
});
|
|
23
24
|
test('should apply a size class when defining a size', function () {
|
|
24
|
-
|
|
25
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Heading["default"], {
|
|
25
26
|
size: "large",
|
|
26
27
|
children: "Heading Text"
|
|
27
28
|
}));
|
|
28
|
-
var expected =
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
var expected = 'large';
|
|
30
|
+
|
|
31
|
+
var actual = _react.screen.getByText('Heading Text');
|
|
32
|
+
|
|
33
|
+
expect(actual).toHaveClass(expected);
|
|
31
34
|
});
|
|
32
35
|
test('should apply a matching spacing class to its defined size', function () {
|
|
33
|
-
|
|
36
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Heading["default"], {
|
|
34
37
|
size: "large",
|
|
35
38
|
children: "Heading Text"
|
|
36
39
|
}));
|
|
37
|
-
var expected =
|
|
38
|
-
|
|
39
|
-
|
|
40
|
+
var expected = 'largeSpacing';
|
|
41
|
+
|
|
42
|
+
var actual = _react.screen.getByText('Heading Text');
|
|
43
|
+
|
|
44
|
+
expect(actual).toHaveClass(expected);
|
|
40
45
|
});
|
|
41
46
|
test('should apply an alternate spacing class to its defined size if the two differ', function () {
|
|
42
|
-
|
|
47
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Heading["default"], {
|
|
43
48
|
size: "large",
|
|
44
49
|
spacing: "small",
|
|
45
50
|
children: "Heading Text"
|
|
46
51
|
}));
|
|
47
|
-
var expected =
|
|
48
|
-
|
|
49
|
-
|
|
52
|
+
var expected = 'smallSpacing';
|
|
53
|
+
|
|
54
|
+
var actual = _react.screen.getByText('Heading Text');
|
|
55
|
+
|
|
56
|
+
expect(actual).toHaveClass(expected);
|
|
50
57
|
});
|
|
51
58
|
test('should return a DOM node reference for `componentRef`', function () {
|
|
52
59
|
var ref = jest.fn();
|
|
53
|
-
(0,
|
|
60
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Heading["default"], {
|
|
54
61
|
size: "large",
|
|
55
62
|
ref: ref
|
|
56
63
|
}));
|
package/Icon/Icon.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export interface IconBaseProps {
|
|
|
11
11
|
* The icon content.
|
|
12
12
|
*
|
|
13
13
|
* May be specified as either:
|
|
14
|
-
* * A string that represents an icon from the
|
|
14
|
+
* * A string that represents an icon from the [iconList] ,
|
|
15
15
|
* * An HTML entity string, Unicode reference or hex value (in the form '0x...'),
|
|
16
16
|
* * A URL specifying path to an icon image, or
|
|
17
17
|
* * An object representing a resolution independent resource (See ).
|
|
@@ -30,8 +30,8 @@ corresponding internal elements and states of this component.
|
|
|
30
30
|
*
|
|
31
31
|
* The following classes are supported:
|
|
32
32
|
* * `icon` - The root component class
|
|
33
|
-
* * `dingbat` - Applied when the value of
|
|
34
|
-
found in
|
|
33
|
+
* * `dingbat` - Applied when the value of [ `icon` ] is not
|
|
34
|
+
found in [iconList]
|
|
35
35
|
* * `large` - Applied when `size` prop is `'large'`
|
|
36
36
|
* * `pressed` - Applied when `pressed` prop is `true`
|
|
37
37
|
* * `small` - Applied when `size` prop is `'small'`
|
|
@@ -58,7 +58,7 @@ renders in a React + JSX string.
|
|
|
58
58
|
* The size of the button.
|
|
59
59
|
*
|
|
60
60
|
* Applies the CSS class which can be customized by
|
|
61
|
-
|
|
61
|
+
[theming] .
|
|
62
62
|
*/
|
|
63
63
|
size?: string;
|
|
64
64
|
}
|
package/Icon/tests/Icon-specs.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
require("@testing-library/jest-dom");
|
|
4
|
+
|
|
5
|
+
var _react = require("@testing-library/react");
|
|
4
6
|
|
|
5
7
|
var _Icon = _interopRequireWildcard(require("../Icon"));
|
|
6
8
|
|
|
@@ -13,30 +15,36 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj;
|
|
|
13
15
|
describe('Icon', function () {
|
|
14
16
|
test('should allow icon-name words to pass through', function () {
|
|
15
17
|
var iconName = 'hollow_star';
|
|
16
|
-
|
|
18
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Icon.IconBase, {
|
|
19
|
+
"data-testid": "icon",
|
|
17
20
|
children: iconName
|
|
18
21
|
}));
|
|
19
|
-
|
|
20
|
-
var
|
|
21
|
-
|
|
22
|
+
|
|
23
|
+
var icon = _react.screen.getByTestId('icon');
|
|
24
|
+
|
|
25
|
+
expect(icon).toHaveTextContent(iconName);
|
|
22
26
|
});
|
|
23
27
|
test('should allow single-byte characters to pass through', function () {
|
|
24
28
|
var iconName = '+';
|
|
25
|
-
|
|
29
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Icon.IconBase, {
|
|
30
|
+
"data-testid": "icon",
|
|
26
31
|
children: iconName
|
|
27
32
|
}));
|
|
28
|
-
|
|
29
|
-
var
|
|
30
|
-
|
|
33
|
+
|
|
34
|
+
var icon = _react.screen.getByTestId('icon');
|
|
35
|
+
|
|
36
|
+
expect(icon).toHaveTextContent(iconName);
|
|
31
37
|
});
|
|
32
38
|
test('should allow multi-byte characters to pass through', function () {
|
|
33
39
|
var iconName = '';
|
|
34
|
-
|
|
40
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Icon.IconBase, {
|
|
41
|
+
"data-testid": "icon",
|
|
35
42
|
children: iconName
|
|
36
43
|
}));
|
|
37
|
-
|
|
38
|
-
var
|
|
39
|
-
|
|
44
|
+
|
|
45
|
+
var icon = _react.screen.getByTestId('icon');
|
|
46
|
+
|
|
47
|
+
expect(icon).toHaveTextContent(iconName);
|
|
40
48
|
});
|
|
41
49
|
test('should allow pre-defined icon names as an icon', function () {
|
|
42
50
|
var iconName = 'factory';
|
|
@@ -45,13 +53,15 @@ describe('Icon', function () {
|
|
|
45
53
|
train: 'T',
|
|
46
54
|
factory: 'F'
|
|
47
55
|
};
|
|
48
|
-
|
|
56
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Icon.IconBase, {
|
|
57
|
+
"data-testid": "icon",
|
|
49
58
|
iconList: iconList,
|
|
50
59
|
children: iconName
|
|
51
60
|
}));
|
|
52
|
-
|
|
53
|
-
var
|
|
54
|
-
|
|
61
|
+
|
|
62
|
+
var icon = _react.screen.getByTestId('icon');
|
|
63
|
+
|
|
64
|
+
expect(icon).toHaveTextContent(iconGlyph);
|
|
55
65
|
});
|
|
56
66
|
test('should allow un-matched icon names to fall through, even when pre-defined icons exist', function () {
|
|
57
67
|
var iconName = 'custom-icon-word';
|
|
@@ -59,54 +69,65 @@ describe('Icon', function () {
|
|
|
59
69
|
train: 'T',
|
|
60
70
|
factory: 'F'
|
|
61
71
|
};
|
|
62
|
-
|
|
72
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Icon.IconBase, {
|
|
73
|
+
"data-testid": "icon",
|
|
63
74
|
iconList: iconList,
|
|
64
75
|
children: iconName
|
|
65
76
|
}));
|
|
66
|
-
|
|
67
|
-
var
|
|
68
|
-
|
|
77
|
+
|
|
78
|
+
var icon = _react.screen.getByTestId('icon');
|
|
79
|
+
|
|
80
|
+
expect(icon).toHaveTextContent(iconName);
|
|
69
81
|
});
|
|
70
82
|
test('should allow URIs to be used as an icon', function () {
|
|
71
83
|
var src = 'images/icon.png';
|
|
72
|
-
|
|
84
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Icon.IconBase, {
|
|
85
|
+
"data-testid": "icon",
|
|
73
86
|
children: src
|
|
74
87
|
}));
|
|
88
|
+
|
|
89
|
+
var icon = _react.screen.getByTestId('icon');
|
|
90
|
+
|
|
75
91
|
var expected = {
|
|
76
92
|
backgroundImage: "url(".concat(src, ")")
|
|
77
93
|
};
|
|
78
|
-
|
|
79
|
-
expect(actual).toEqual(expected);
|
|
94
|
+
expect(icon).toHaveStyle(expected);
|
|
80
95
|
});
|
|
81
96
|
test('should allow URLs to be used as an icon', function () {
|
|
82
97
|
var src = 'http://enactjs.com/images/logo';
|
|
83
|
-
|
|
98
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Icon.IconBase, {
|
|
99
|
+
"data-testid": "icon",
|
|
84
100
|
children: src
|
|
85
101
|
}));
|
|
102
|
+
|
|
103
|
+
var icon = _react.screen.getByTestId('icon');
|
|
104
|
+
|
|
86
105
|
var expected = {
|
|
87
106
|
backgroundImage: "url(".concat(src, ")")
|
|
88
107
|
};
|
|
89
|
-
|
|
90
|
-
expect(actual).toEqual(expected);
|
|
108
|
+
expect(icon).toHaveStyle(expected);
|
|
91
109
|
});
|
|
92
110
|
test('should merge author styles with image URLs', function () {
|
|
93
111
|
var src = 'images/icon.png';
|
|
94
|
-
|
|
112
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Icon.IconBase, {
|
|
113
|
+
"data-testid": "icon",
|
|
95
114
|
style: {
|
|
96
115
|
color: 'green'
|
|
97
116
|
},
|
|
98
117
|
children: src
|
|
99
118
|
}));
|
|
119
|
+
|
|
120
|
+
var icon = _react.screen.getByTestId('icon');
|
|
121
|
+
|
|
100
122
|
var expected = {
|
|
101
123
|
color: 'green',
|
|
102
124
|
backgroundImage: "url(".concat(src, ")")
|
|
103
125
|
};
|
|
104
|
-
|
|
105
|
-
expect(actual).toEqual(expected);
|
|
126
|
+
expect(icon).toHaveStyle(expected);
|
|
106
127
|
});
|
|
107
128
|
test('should return a DOM node reference for `componentRef`', function () {
|
|
108
129
|
var ref = jest.fn();
|
|
109
|
-
(0,
|
|
130
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Icon["default"], {
|
|
110
131
|
ref: ref
|
|
111
132
|
}));
|
|
112
133
|
var expected = 'DIV';
|
|
@@ -14,7 +14,7 @@ export interface IconButtonBaseProps {
|
|
|
14
14
|
*/
|
|
15
15
|
buttonComponent: React.ComponentType | JSX.Element;
|
|
16
16
|
/**
|
|
17
|
-
* The component used to render the
|
|
17
|
+
* The component used to render the [icon] .
|
|
18
18
|
*
|
|
19
19
|
* This component will receive the `flip` and `size` property set on the `IconButton` as well as the
|
|
20
20
|
`icon` class to customize its styling.
|
|
@@ -39,7 +39,7 @@ corresponding internal elements and states of this component.
|
|
|
39
39
|
*
|
|
40
40
|
* The following classes are supported:
|
|
41
41
|
* * `iconButton` - The root component class
|
|
42
|
-
* * `icon` - The
|
|
42
|
+
* * `icon` - The [icon component] class
|
|
43
43
|
* * `large` - Applied when `size` prop is `'large'`
|
|
44
44
|
* * `small` - Applied when `size` prop is `'small'`
|
|
45
45
|
* * `pressed` - Applied when `pressed` prop is `true`
|
|
@@ -49,7 +49,7 @@ corresponding internal elements and states of this component.
|
|
|
49
49
|
* Disables IconButton.
|
|
50
50
|
*
|
|
51
51
|
* When `true` , the button is shown as disabled and does not generate
|
|
52
|
-
`onClick`
|
|
52
|
+
`onClick` [events] .
|
|
53
53
|
*/
|
|
54
54
|
disabled?: boolean;
|
|
55
55
|
/**
|
|
@@ -74,7 +74,7 @@ corresponding internal elements and states of this component.
|
|
|
74
74
|
* The size of the button.
|
|
75
75
|
*
|
|
76
76
|
* Applies the CSS class which can be customized by
|
|
77
|
-
|
|
77
|
+
[theming] .
|
|
78
78
|
*/
|
|
79
79
|
size?: string;
|
|
80
80
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var _react = require("react");
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var _react2 = require("@testing-library/react");
|
|
6
6
|
|
|
7
7
|
var _IconButton = _interopRequireDefault(require("../IconButton"));
|
|
8
8
|
|
|
@@ -23,7 +23,7 @@ describe('IconButton', function () {
|
|
|
23
23
|
|
|
24
24
|
test('should return a DOM node reference for `componentRef`', function () {
|
|
25
25
|
var ref = jest.fn();
|
|
26
|
-
(0,
|
|
26
|
+
(0, _react2.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_IconButton["default"], {
|
|
27
27
|
ref: ref,
|
|
28
28
|
buttonComponent: Button,
|
|
29
29
|
iconComponent: Icon,
|