@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
|
-
var
|
|
3
|
+
var _react = require("@testing-library/react");
|
|
4
|
+
|
|
5
|
+
var _react2 = require("react");
|
|
4
6
|
|
|
5
7
|
var _Announce = _interopRequireDefault(require("../Announce"));
|
|
6
8
|
|
|
@@ -10,16 +12,22 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "d
|
|
|
10
12
|
|
|
11
13
|
describe('Announce', function () {
|
|
12
14
|
test('should have an announce method on the component', function () {
|
|
13
|
-
var
|
|
14
|
-
|
|
15
|
+
var ref = /*#__PURE__*/(0, _react2.createRef)();
|
|
16
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Announce["default"], {
|
|
17
|
+
ref: ref
|
|
18
|
+
}));
|
|
19
|
+
var node = ref.current;
|
|
15
20
|
var expected = 'function';
|
|
16
21
|
var actual = typeof node.announce;
|
|
17
22
|
expect(actual).toBe(expected);
|
|
18
23
|
});
|
|
19
24
|
test('should update the aria-label with the provided message', function () {
|
|
25
|
+
var ref = /*#__PURE__*/(0, _react2.createRef)();
|
|
20
26
|
var message = 'message';
|
|
21
|
-
|
|
22
|
-
|
|
27
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Announce["default"], {
|
|
28
|
+
ref: ref
|
|
29
|
+
}));
|
|
30
|
+
var node = ref.current;
|
|
23
31
|
node.announce(message);
|
|
24
32
|
var expected = message; // since we're manually updating the node in Announce, we have to manually check the node here
|
|
25
33
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _react = require("@testing-library/react");
|
|
4
4
|
|
|
5
5
|
var _AnnounceDecorator = _interopRequireDefault(require("../AnnounceDecorator"));
|
|
6
6
|
|
|
@@ -9,16 +9,18 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
9
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
10
10
|
|
|
11
11
|
describe('AnnounceDecorator', function () {
|
|
12
|
-
// no-op wrapper
|
|
13
|
-
|
|
12
|
+
var announceProps; // no-op wrapper
|
|
13
|
+
|
|
14
|
+
var Div = function Div(props) {
|
|
15
|
+
announceProps = props;
|
|
14
16
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {});
|
|
15
17
|
};
|
|
16
18
|
|
|
17
19
|
test('should pass a function in the announce prop', function () {
|
|
18
20
|
var Component = (0, _AnnounceDecorator["default"])(Div);
|
|
19
|
-
|
|
21
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {}));
|
|
20
22
|
var expected = 'function';
|
|
21
|
-
var actual = typeof
|
|
23
|
+
var actual = typeof announceProps.announce;
|
|
22
24
|
expect(actual).toBe(expected);
|
|
23
25
|
});
|
|
24
26
|
test('should allow prop to be configured for announce function', function () {
|
|
@@ -26,9 +28,9 @@ describe('AnnounceDecorator', function () {
|
|
|
26
28
|
var Component = (0, _AnnounceDecorator["default"])({
|
|
27
29
|
prop: prop
|
|
28
30
|
}, Div);
|
|
29
|
-
|
|
31
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {}));
|
|
30
32
|
var expected = 'function';
|
|
31
|
-
var actual = typeof
|
|
33
|
+
var actual = typeof announceProps[prop];
|
|
32
34
|
expect(actual).toBe(expected);
|
|
33
35
|
});
|
|
34
36
|
});
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _react = require("react");
|
|
4
|
-
|
|
5
|
-
var _enzyme = require("enzyme");
|
|
3
|
+
var _react = require("@testing-library/react");
|
|
6
4
|
|
|
7
5
|
var _useAnnounce2 = _interopRequireDefault(require("../useAnnounce"));
|
|
8
6
|
|
|
@@ -11,9 +9,14 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
11
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
12
10
|
|
|
13
11
|
describe('useAnnounce', function () {
|
|
12
|
+
var announceType;
|
|
13
|
+
|
|
14
14
|
function Base(_ref) {
|
|
15
|
-
var children = _ref.children
|
|
15
|
+
var children = _ref.children,
|
|
16
|
+
announce = _ref.announce;
|
|
17
|
+
announceType = typeof announce;
|
|
16
18
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
19
|
+
"data-testid": "announce",
|
|
17
20
|
children: children
|
|
18
21
|
});
|
|
19
22
|
}
|
|
@@ -30,28 +33,33 @@ describe('useAnnounce', function () {
|
|
|
30
33
|
}
|
|
31
34
|
|
|
32
35
|
test('should return an announce function', function () {
|
|
33
|
-
|
|
36
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {}));
|
|
34
37
|
var expected = 'function';
|
|
35
|
-
|
|
36
|
-
expect(actual).toBe(expected);
|
|
38
|
+
expect(announceType).toBe(expected);
|
|
37
39
|
});
|
|
38
40
|
test('should return a single element in children', function () {
|
|
39
|
-
|
|
40
|
-
var expected =
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {}));
|
|
42
|
+
var expected = 1;
|
|
43
|
+
|
|
44
|
+
var baseElementChildrenCount = _react.screen.getByTestId('announce').children.length;
|
|
45
|
+
|
|
46
|
+
expect(baseElementChildrenCount).toBe(expected);
|
|
47
|
+
}); // this might be too specialized to the implementation but we lack a better way to unit test this
|
|
44
48
|
// capability right now
|
|
49
|
+
// TODO: find a relevant scenario that works on testing-library
|
|
45
50
|
|
|
46
|
-
test('should set the value passed to announce into the ARIA role="alert" node', function () {
|
|
51
|
+
test.skip('should set the value passed to announce into the ARIA role="alert" node', function () {
|
|
47
52
|
var text = '__NOTIFY__';
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
53
|
+
|
|
54
|
+
var _render = (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {})),
|
|
55
|
+
container = _render.container;
|
|
56
|
+
|
|
57
|
+
container.find(Base).invoke('announce')(text);
|
|
58
|
+
container.update();
|
|
51
59
|
var expected = text; // Have to get the actual DOM node here since Announce updates the DOM directly so the
|
|
52
60
|
// change isn't represented in either the React or Enzyme views
|
|
53
61
|
|
|
54
|
-
var actual =
|
|
62
|
+
var actual = container.find({
|
|
55
63
|
role: 'alert'
|
|
56
64
|
}).instance().getAttribute('aria-label');
|
|
57
65
|
expect(actual).toBe(expected);
|
package/BodyText/BodyText.d.ts
CHANGED
|
@@ -1,17 +1,15 @@
|
|
|
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
7
|
var _Layout = require("../../Layout");
|
|
8
8
|
|
|
9
|
-
var
|
|
9
|
+
var _BodyText = _interopRequireWildcard(require("../BodyText"));
|
|
10
10
|
|
|
11
11
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
12
12
|
|
|
13
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
14
|
-
|
|
15
13
|
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
|
|
16
14
|
|
|
17
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; }
|
|
@@ -19,53 +17,69 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj;
|
|
|
19
17
|
describe('BodyText Specs', function () {
|
|
20
18
|
test('should render a single <p> tag', function () {
|
|
21
19
|
var msg = 'Hello BodyText!';
|
|
22
|
-
|
|
20
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_BodyText["default"], {
|
|
23
21
|
children: msg
|
|
24
22
|
}));
|
|
25
|
-
var
|
|
26
|
-
|
|
27
|
-
var actual =
|
|
23
|
+
var expected = 'P';
|
|
24
|
+
|
|
25
|
+
var actual = _react.screen.getByText(msg).nodeName;
|
|
26
|
+
|
|
28
27
|
expect(actual).toBe(expected);
|
|
29
28
|
});
|
|
30
29
|
test('should render BodyText with content', function () {
|
|
31
30
|
var content = 'Hello BodyText!';
|
|
32
|
-
|
|
31
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_BodyText["default"], {
|
|
33
32
|
children: content
|
|
34
33
|
}));
|
|
35
|
-
|
|
36
|
-
var
|
|
37
|
-
|
|
34
|
+
|
|
35
|
+
var bodyText = _react.screen.getByText(content);
|
|
36
|
+
|
|
37
|
+
expect(bodyText).toBeInTheDocument();
|
|
38
38
|
});
|
|
39
39
|
test('should not include the centered class by default', function () {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
var actual = subject.hasClass(_BodyTextModule["default"].centered);
|
|
43
|
-
expect(actual).toBe(expected);
|
|
44
|
-
});
|
|
45
|
-
test('should include the centered class if `centered` is true', function () {
|
|
46
|
-
var subject = (0, _enzyme.shallow)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_BodyText.BodyTextBase, {
|
|
47
|
-
centered: true
|
|
40
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_BodyText.BodyTextBase, {
|
|
41
|
+
"data-testid": "bodyText"
|
|
48
42
|
}));
|
|
49
|
-
|
|
50
|
-
var
|
|
51
|
-
|
|
43
|
+
|
|
44
|
+
var bodyText = _react.screen.getByTestId('bodyText');
|
|
45
|
+
|
|
46
|
+
var expected = 'centered';
|
|
47
|
+
expect(bodyText).not.toHaveClass(expected);
|
|
52
48
|
});
|
|
53
|
-
test('should
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
49
|
+
test('should include the centered class if `centered` is true', function () {
|
|
50
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_BodyText["default"], {
|
|
51
|
+
centered: true,
|
|
52
|
+
"data-testid": "bodyText"
|
|
57
53
|
}));
|
|
58
|
-
|
|
59
|
-
var
|
|
60
|
-
|
|
54
|
+
|
|
55
|
+
var bodyText = _react.screen.getByTestId('bodyText');
|
|
56
|
+
|
|
57
|
+
var expected = 'centered';
|
|
58
|
+
expect(bodyText).toHaveClass(expected);
|
|
61
59
|
});
|
|
62
60
|
test('should support changing the component element to a functional component', function () {
|
|
63
61
|
var component = _Layout.Cell;
|
|
64
|
-
|
|
65
|
-
component: component
|
|
62
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_BodyText.BodyTextBase, {
|
|
63
|
+
component: component,
|
|
64
|
+
"data-testid": "bodyText"
|
|
65
|
+
}));
|
|
66
|
+
|
|
67
|
+
var bodyText = _react.screen.getByTestId('bodyText');
|
|
68
|
+
|
|
69
|
+
var expected = 'cell';
|
|
70
|
+
expect(bodyText).toHaveClass(expected);
|
|
71
|
+
});
|
|
72
|
+
test('should support changing the component element to a different DOM node', function () {
|
|
73
|
+
var componentTag = 'address';
|
|
74
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_BodyText.BodyTextBase, {
|
|
75
|
+
component: componentTag,
|
|
76
|
+
"data-testid": "bodyText"
|
|
66
77
|
}));
|
|
67
|
-
|
|
68
|
-
var
|
|
78
|
+
|
|
79
|
+
var bodyText = _react.screen.getByTestId('bodyText');
|
|
80
|
+
|
|
81
|
+
var expected = 'ADDRESS';
|
|
82
|
+
var actual = bodyText.nodeName;
|
|
69
83
|
expect(actual).toBe(expected);
|
|
70
84
|
});
|
|
71
85
|
});
|
package/Button/Button.d.ts
CHANGED
|
@@ -55,10 +55,10 @@ externally.
|
|
|
55
55
|
*/
|
|
56
56
|
icon?: React.ReactNode | boolean;
|
|
57
57
|
/**
|
|
58
|
-
* The component used to render the
|
|
58
|
+
* The component used to render the [icon] .
|
|
59
59
|
*
|
|
60
60
|
* This component will receive the `icon` class to customize its styling.
|
|
61
|
-
If
|
|
61
|
+
If [icon] is not assigned or is false, this component
|
|
62
62
|
will not be rendered.
|
|
63
63
|
*
|
|
64
64
|
* If this is a component rather than an HTML element string, this component will also
|
|
@@ -74,28 +74,28 @@ handle it.
|
|
|
74
74
|
* Enforces a minimum width for the component.
|
|
75
75
|
*
|
|
76
76
|
* Applies the `minWidth` CSS class which can be customized by
|
|
77
|
-
|
|
77
|
+
[theming] .
|
|
78
78
|
*/
|
|
79
79
|
minWidth?: boolean;
|
|
80
80
|
/**
|
|
81
81
|
* Indicates the component is depressed.
|
|
82
82
|
*
|
|
83
83
|
* Applies the `pressed` CSS class which can be customized by
|
|
84
|
-
|
|
84
|
+
[theming] .
|
|
85
85
|
*/
|
|
86
86
|
pressed?: boolean;
|
|
87
87
|
/**
|
|
88
88
|
* Indicates the component is selected.
|
|
89
89
|
*
|
|
90
90
|
* Applies the `selected` CSS class which can be customized by
|
|
91
|
-
|
|
91
|
+
[theming] .
|
|
92
92
|
*/
|
|
93
93
|
selected?: boolean;
|
|
94
94
|
/**
|
|
95
95
|
* The size of the button.
|
|
96
96
|
*
|
|
97
97
|
* Applies the CSS class which can be customized by
|
|
98
|
-
|
|
98
|
+
[theming] .
|
|
99
99
|
*/
|
|
100
100
|
size?: string;
|
|
101
101
|
}
|
|
@@ -1,8 +1,12 @@
|
|
|
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
|
+
|
|
7
|
+
var _userEvent = _interopRequireDefault(require("@testing-library/user-event"));
|
|
8
|
+
|
|
9
|
+
var _Button = require("../Button");
|
|
6
10
|
|
|
7
11
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
8
12
|
|
|
@@ -11,11 +15,108 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "d
|
|
|
11
15
|
describe('Button', function () {
|
|
12
16
|
test('should return a DOM node reference for `componentRef`', function () {
|
|
13
17
|
var ref = jest.fn();
|
|
14
|
-
(0,
|
|
18
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Button.Button, {
|
|
15
19
|
ref: ref
|
|
16
20
|
}));
|
|
17
21
|
var expected = 'DIV';
|
|
18
22
|
var actual = ref.mock.calls[0][0].nodeName;
|
|
19
23
|
expect(actual).toBe(expected);
|
|
20
24
|
});
|
|
25
|
+
test('should have \'disabled\' HTML attribute when \'disabled\' prop is provided', function () {
|
|
26
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Button.Button, {
|
|
27
|
+
disabled: true,
|
|
28
|
+
children: "I am a disabled Button"
|
|
29
|
+
}));
|
|
30
|
+
|
|
31
|
+
var button = _react.screen.getByRole('button');
|
|
32
|
+
|
|
33
|
+
expect(button).toHaveAttribute('disabled');
|
|
34
|
+
});
|
|
35
|
+
test('should have default minWidth class', function () {
|
|
36
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Button.ButtonBase, {}));
|
|
37
|
+
|
|
38
|
+
var button = _react.screen.getByRole('button');
|
|
39
|
+
|
|
40
|
+
var expected = 'minWidth';
|
|
41
|
+
expect(button).toHaveClass(expected);
|
|
42
|
+
});
|
|
43
|
+
test('should have selected class when selected prop is set to true', function () {
|
|
44
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Button.ButtonBase, {
|
|
45
|
+
selected: true
|
|
46
|
+
}));
|
|
47
|
+
|
|
48
|
+
var button = _react.screen.getByRole('button');
|
|
49
|
+
|
|
50
|
+
var expected = 'selected';
|
|
51
|
+
expect(button).toHaveClass(expected);
|
|
52
|
+
});
|
|
53
|
+
test('should have pressed class when pressed prop is set to true', function () {
|
|
54
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Button.ButtonBase, {
|
|
55
|
+
pressed: true
|
|
56
|
+
}));
|
|
57
|
+
|
|
58
|
+
var button = _react.screen.getByRole('button');
|
|
59
|
+
|
|
60
|
+
var expected = 'pressed';
|
|
61
|
+
expect(button).toHaveClass(expected);
|
|
62
|
+
});
|
|
63
|
+
test('should have large class when size prop is set to large', function () {
|
|
64
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Button.ButtonBase, {
|
|
65
|
+
size: "large"
|
|
66
|
+
}));
|
|
67
|
+
|
|
68
|
+
var button = _react.screen.getByRole('button');
|
|
69
|
+
|
|
70
|
+
var expected = 'large';
|
|
71
|
+
expect(button).toHaveClass(expected);
|
|
72
|
+
});
|
|
73
|
+
test('should have small class when size prop is set to small', function () {
|
|
74
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Button.ButtonBase, {
|
|
75
|
+
size: "small"
|
|
76
|
+
}));
|
|
77
|
+
|
|
78
|
+
var button = _react.screen.getByRole('button');
|
|
79
|
+
|
|
80
|
+
var expected = 'small';
|
|
81
|
+
expect(button).toHaveClass(expected);
|
|
82
|
+
});
|
|
83
|
+
test('should have hasIcon class when icon prop is defined', function () {
|
|
84
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Button.Button, {
|
|
85
|
+
icon: true,
|
|
86
|
+
children: "Hello Button!"
|
|
87
|
+
}));
|
|
88
|
+
|
|
89
|
+
var button = _react.screen.getByRole('button');
|
|
90
|
+
|
|
91
|
+
var expected = 'hasIcon';
|
|
92
|
+
expect(button).toHaveClass(expected);
|
|
93
|
+
});
|
|
94
|
+
test('should call onClick', function () {
|
|
95
|
+
var handleCLick = jest.fn();
|
|
96
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Button.Button, {
|
|
97
|
+
onClick: handleCLick,
|
|
98
|
+
children: "Hello Button!"
|
|
99
|
+
}));
|
|
100
|
+
|
|
101
|
+
var button = _react.screen.getByRole('button');
|
|
102
|
+
|
|
103
|
+
_userEvent["default"].click(button);
|
|
104
|
+
|
|
105
|
+
var expected = 1;
|
|
106
|
+
expect(handleCLick).toHaveBeenCalledTimes(expected);
|
|
107
|
+
});
|
|
108
|
+
test('should not call onClick when button is disabled', function () {
|
|
109
|
+
var handleClick = jest.fn();
|
|
110
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Button.Button, {
|
|
111
|
+
disabled: true,
|
|
112
|
+
onClick: handleClick,
|
|
113
|
+
children: "Hello Button!"
|
|
114
|
+
}));
|
|
115
|
+
|
|
116
|
+
var button = _react.screen.getByRole('button');
|
|
117
|
+
|
|
118
|
+
_userEvent["default"].click(button);
|
|
119
|
+
|
|
120
|
+
expect(handleClick).not.toHaveBeenCalled();
|
|
121
|
+
});
|
|
21
122
|
});
|
package/CHANGELOG.md
CHANGED
package/Cancelable/Cancelable.js
CHANGED
|
@@ -208,7 +208,7 @@ var Cancelable = (0, _hoc["default"])(defaultConfig, function (config, Wrapped)
|
|
|
208
208
|
|
|
209
209
|
_this = _super.call(this, props);
|
|
210
210
|
_this.handle = _handle.handle.bind(_assertThisInitialized(_this));
|
|
211
|
-
_this.handleCancel = _this.handle(_cancelHandler.forCancel, (0, _handle.
|
|
211
|
+
_this.handleCancel = _this.handle(_cancelHandler.forCancel, (0, _handle.forwardCustom)('onCancel'), dispatchCancelToConfig, _handle.stop, _handle.stopImmediate);
|
|
212
212
|
_this.handleKeyUp = _this.handle((0, _handle.forward)('onKeyUp'), // nesting handlers for DRYness. note that if any conditions return false in
|
|
213
213
|
// this.handleCancel(), this handler chain will stop too
|
|
214
214
|
_this.handleCancel);
|