linear-react-components-ui 1.0.10-rc.2 → 1.0.10-rc.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.
Files changed (93) hide show
  1. package/coverage/clover.xml +6 -0
  2. package/coverage/coverage-final.json +1 -0
  3. package/coverage/lcov-report/base.css +224 -0
  4. package/coverage/lcov-report/block-navigation.js +87 -0
  5. package/coverage/lcov-report/favicon.png +0 -0
  6. package/coverage/lcov-report/index.html +101 -0
  7. package/coverage/lcov-report/prettify.css +1 -0
  8. package/coverage/lcov-report/prettify.js +2 -0
  9. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  10. package/coverage/lcov-report/sorter.js +196 -0
  11. package/coverage/lcov.info +0 -0
  12. package/demo/06c001f4d19c06397d470bb43ff3fe49.png +0 -0
  13. package/demo/270084ef02ed3bddc3f735fd91ee3cae.png +0 -0
  14. package/demo/882f8e819d18f5f2dc08d23ebd28a7d5.png +0 -0
  15. package/demo/bundle.js +2 -0
  16. package/demo/bundle.js.LICENSE.txt +65 -0
  17. package/demo/cbc3b4bd6342c551db7afafe26dc458c.jpg +0 -0
  18. package/demo/edc9476523b940deab91951066981a31.png +0 -0
  19. package/demo/fb44e7c36db6d95bb85a745d4f060fb2.png +0 -0
  20. package/demo/fonts/Roboto-Black.woff +0 -0
  21. package/demo/fonts/Roboto-Black.woff2 +0 -0
  22. package/demo/fonts/Roboto-Bold.woff +0 -0
  23. package/demo/fonts/Roboto-Bold.woff2 +0 -0
  24. package/demo/fonts/Roboto-Light.woff +0 -0
  25. package/demo/fonts/Roboto-Light.woff2 +0 -0
  26. package/demo/fonts/Roboto-Medium.woff +0 -0
  27. package/demo/fonts/Roboto-Medium.woff2 +0 -0
  28. package/demo/fonts/Roboto-Regular.woff +0 -0
  29. package/demo/fonts/Roboto-Regular.woff2 +0 -0
  30. package/demo/fonts/Roboto-Thin.woff +0 -0
  31. package/demo/fonts/Roboto-Thin.woff2 +0 -0
  32. package/demo/fonts/TitilliumWeb-Black.woff +0 -0
  33. package/demo/fonts/TitilliumWeb-Black.woff2 +0 -0
  34. package/demo/fonts/TitilliumWeb-Bold.woff +0 -0
  35. package/demo/fonts/TitilliumWeb-Bold.woff2 +0 -0
  36. package/demo/fonts/TitilliumWeb-ExtraLight.woff +0 -0
  37. package/demo/fonts/TitilliumWeb-ExtraLight.woff2 +0 -0
  38. package/demo/fonts/TitilliumWeb-Light.woff +0 -0
  39. package/demo/fonts/TitilliumWeb-Light.woff2 +0 -0
  40. package/demo/fonts/TitilliumWeb-Regular.woff +0 -0
  41. package/demo/fonts/TitilliumWeb-Regular.woff2 +0 -0
  42. package/demo/fonts/TitilliumWeb-SemiBold.woff +0 -0
  43. package/demo/fonts/TitilliumWeb-SemiBold.woff2 +0 -0
  44. package/demo/index.html +1 -0
  45. package/lib/inputs/mask/helpers.js +1 -1
  46. package/lib/inputs/number/format_number.js +1 -6
  47. package/lib/inputs/textarea/index.js +1 -1
  48. package/lib/table/Body.js +9 -12
  49. package/lib/table/Header.js +19 -16
  50. package/lib/table/index.js +1 -0
  51. package/lib/table/types.d.ts +2 -0
  52. package/package.json +1 -1
  53. package/lib/alerts/alert.spec.js +0 -133
  54. package/lib/avatar/avatar.spec.js +0 -190
  55. package/lib/badge/badge.spec.js +0 -127
  56. package/lib/buttons/SpinnerLoading.js +0 -230
  57. package/lib/buttons/buttons.spec.js +0 -504
  58. package/lib/calendar/calendar.spec.js +0 -171
  59. package/lib/checkbox/checkbox.spec.js +0 -215
  60. package/lib/dialog/dialog.spec.js +0 -488
  61. package/lib/drawer/Drawer.spec.js +0 -258
  62. package/lib/dropdown/dropdown.spec.js +0 -169
  63. package/lib/fieldset/fieldset.spec.js +0 -329
  64. package/lib/form/form.spec.js +0 -293
  65. package/lib/gridlayout/gridLayout.spec.js +0 -169
  66. package/lib/icons/icons.spec.js +0 -86
  67. package/lib/inputs/base/base.spec.js +0 -690
  68. package/lib/inputs/base/index.js +0 -1
  69. package/lib/inputs/color/color_input.spec.js +0 -174
  70. package/lib/inputs/date/date.spec.js +0 -354
  71. package/lib/inputs/mask/input_mask.spec.js +0 -607
  72. package/lib/inputs/number/numberfield.spec.js +0 -215
  73. package/lib/inputs/search/search_input.spec.js +0 -209
  74. package/lib/inputs/select/select.spec.js +0 -395
  75. package/lib/inputs/text/textfield.spec.js +0 -215
  76. package/lib/inputs/textarea/textarea.spec.js +0 -59
  77. package/lib/labelMessages/labelMessages.spec.js +0 -176
  78. package/lib/labels/label.spec.js +0 -162
  79. package/lib/list/list.spec.js +0 -769
  80. package/lib/menus/float/float-menu.spec.js +0 -221
  81. package/lib/menus/sidenav/sidenav.spec.js +0 -379
  82. package/lib/panel/panel.spec.js +0 -216
  83. package/lib/popover/popover.spec.js +0 -146
  84. package/lib/progress/progress.spec.js +0 -94
  85. package/lib/radio/radio.spec.js +0 -189
  86. package/lib/spinner/spinner.spec.js +0 -152
  87. package/lib/split/split.spec.js +0 -163
  88. package/lib/table/table.spec.js +0 -352
  89. package/lib/tabs/tabs.spec.js +0 -321
  90. package/lib/toolbar/toolbar.spec.js +0 -394
  91. package/lib/tooltip/tooltip.spec.js +0 -215
  92. package/lib/treeview/treeview.spec.js +0 -279
  93. package/lib/uitour/uitour.spec.js +0 -176
@@ -0,0 +1,65 @@
1
+ /*
2
+ object-assign
3
+ (c) Sindre Sorhus
4
+ @license MIT
5
+ */
6
+
7
+ /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
8
+
9
+ /**
10
+ * @license
11
+ * Lodash <https://lodash.com/>
12
+ * Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
13
+ * Released under MIT license <https://lodash.com/license>
14
+ * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
15
+ * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
16
+ */
17
+
18
+ /**
19
+ * Prism: Lightweight, robust, elegant syntax highlighting
20
+ *
21
+ * @license MIT <https://opensource.org/licenses/MIT>
22
+ * @author Lea Verou <https://lea.verou.me>
23
+ * @namespace
24
+ * @public
25
+ */
26
+
27
+ /** @license React v0.19.1
28
+ * scheduler.production.min.js
29
+ *
30
+ * Copyright (c) Facebook, Inc. and its affiliates.
31
+ *
32
+ * This source code is licensed under the MIT license found in the
33
+ * LICENSE file in the root directory of this source tree.
34
+ */
35
+
36
+ /** @license React v16.13.1
37
+ * react-is.production.min.js
38
+ *
39
+ * Copyright (c) Facebook, Inc. and its affiliates.
40
+ *
41
+ * This source code is licensed under the MIT license found in the
42
+ * LICENSE file in the root directory of this source tree.
43
+ */
44
+
45
+ /** @license React v16.14.0
46
+ * react-dom.production.min.js
47
+ *
48
+ * Copyright (c) Facebook, Inc. and its affiliates.
49
+ *
50
+ * This source code is licensed under the MIT license found in the
51
+ * LICENSE file in the root directory of this source tree.
52
+ */
53
+
54
+ /** @license React v16.14.0
55
+ * react.production.min.js
56
+ *
57
+ * Copyright (c) Facebook, Inc. and its affiliates.
58
+ *
59
+ * This source code is licensed under the MIT license found in the
60
+ * LICENSE file in the root directory of this source tree.
61
+ */
62
+
63
+ //! moment.js
64
+
65
+ //! moment.js locale configuration
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1 @@
1
+ <!doctype html><html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width,initial-scale=1"><meta http-equiv="X-UA-Compatible" content="ie=edge"><meta name="description" content="CHANGE THIS"><title>React component starter</title><script defer="defer" src="bundle.js"></script></head><body><div id="app"></div></body></html>
@@ -7,7 +7,7 @@ exports.CNPJValidation = CNPJValidation;
7
7
  exports.CPFValidation = CPFValidation;
8
8
  exports.extractNonMaskProps = extractNonMaskProps;
9
9
  var _lodash = require("lodash");
10
- function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } /* eslint-disable @typescript-eslint/no-explicit-any */
10
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
11
11
  /* eslint-disable no-plusplus */
12
12
  function extractNonMaskProps(props, maskProps) {
13
13
  var nonMask = _extends({}, props);
@@ -21,11 +21,6 @@ var numberToEnUS = function numberToEnUS(value) {
21
21
  };
22
22
  exports.numberToEnUS = numberToEnUS;
23
23
  var formatCnpjCpfField = function formatCnpjCpfField(value) {
24
- var formattedString;
25
- if (value) {
26
- formattedString = value.replace(/[._\-/]/g, '');
27
- return formattedString;
28
- }
29
- return value;
24
+ return value.replace(/[._\-/]/g, '');
30
25
  };
31
26
  exports.formatCnpjCpfField = formatCnpjCpfField;
@@ -7,7 +7,7 @@ exports.default = void 0;
7
7
  var _react = _interopRequireDefault(require("react"));
8
8
  var _InputTextBase = _interopRequireDefault(require("../base/InputTextBase"));
9
9
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
- function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } // eslint-disable-next-line import/no-named-as-default
10
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
11
11
  var TextArea = function TextArea(props) {
12
12
  var rows = props.rows,
13
13
  cols = props.cols,
package/lib/table/Body.js CHANGED
@@ -12,16 +12,15 @@ var _index = require("./index");
12
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
13
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
14
14
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && 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; }
15
- function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
16
- var renderChildren = function renderChildren(_ref) {
17
- var children = _ref.children,
18
- columnsCount = _ref.columnsCount,
15
+ var renderChildren = function renderChildren(children, _ref) {
16
+ var columnsCount = _ref.columnsCount,
19
17
  vertical = _ref.vertical,
20
18
  skeletonize = _ref.skeletonize,
21
19
  _ref$skeletonInRows = _ref.skeletonInRows,
22
20
  skeletonInRows = _ref$skeletonInRows === void 0 ? 10 : _ref$skeletonInRows,
23
21
  _ref$skeletonHeight = _ref.skeletonHeight,
24
- skeletonHeight = _ref$skeletonHeight === void 0 ? 16 : _ref$skeletonHeight;
22
+ skeletonHeight = _ref$skeletonHeight === void 0 ? 16 : _ref$skeletonHeight,
23
+ columnsWidth = _ref.columnsWidth;
25
24
  if (skeletonize && !vertical && columnsCount && skeletonInRows) {
26
25
  var rows = (0, _helpers.getArrayFromNumber)(skeletonInRows);
27
26
  var columns = (0, _helpers.getArrayFromNumber)(columnsCount);
@@ -31,6 +30,9 @@ var renderChildren = function renderChildren(_ref) {
31
30
  key: index
32
31
  }, columns.map(function (id) {
33
32
  return /*#__PURE__*/_react.default.createElement(_index.Td, {
33
+ style: {
34
+ width: columnsWidth === null || columnsWidth === void 0 ? void 0 : columnsWidth[id - 1]
35
+ },
34
36
  key: id
35
37
  }, /*#__PURE__*/_react.default.createElement(_skeleton.default, {
36
38
  height: skeletonHeight
@@ -60,18 +62,13 @@ var TableBody = function TableBody(_ref2) {
60
62
  }, /*#__PURE__*/_react.default.createElement("table", {
61
63
  className: "innertable",
62
64
  style: {
63
- tableLayout: 'fixed',
64
65
  contain: strict ? 'strict' : 'size layout style'
65
66
  }
66
67
  }, /*#__PURE__*/_react.default.createElement("tbody", {
67
68
  className: "tbody ".concat(isSkeletonized ? 'skeleton-transparency' : '', " ").concat(customClass)
68
- }, renderChildren(_extends({}, context, {
69
- children: children
70
- }))))) : /*#__PURE__*/_react.default.createElement("tbody", {
69
+ }, renderChildren(children, context)))) : /*#__PURE__*/_react.default.createElement("tbody", {
71
70
  className: "tbody ".concat(isSkeletonized ? 'skeleton-transparency' : '', " ").concat(customClass)
72
- }, renderChildren(_extends({}, context, {
73
- children: children
74
- })));
71
+ }, renderChildren(children, context));
75
72
  };
76
73
  var _default = TableBody;
77
74
  exports.default = _default;
@@ -20,44 +20,46 @@ var getColumnsWidth = function getColumnsWidth(children) {
20
20
  var colWidth = 0;
21
21
  if (_lodash.default.isArray(element)) {
22
22
  element.forEach(function (elementArray) {
23
- if (elementArray && elementArray.props.style && elementArray.props.style.width) {
24
- colWidth = elementArray.props.style.width;
23
+ if (elementArray && elementArray.props) {
24
+ var _elementArray$props, _elementArray$props$s;
25
+ colWidth = (_elementArray$props = elementArray.props) === null || _elementArray$props === void 0 ? void 0 : (_elementArray$props$s = _elementArray$props.style) === null || _elementArray$props$s === void 0 ? void 0 : _elementArray$props$s.width;
25
26
  }
26
27
  columnsWidth.push(colWidth);
27
28
  });
28
- } else if (element && element.props.style && element.props.style.width) {
29
- colWidth = element.props.style.width;
29
+ } else if (element && element.props) {
30
+ var _element$props, _element$props$style;
31
+ colWidth = (_element$props = element.props) === null || _element$props === void 0 ? void 0 : (_element$props$style = _element$props.style) === null || _element$props$style === void 0 ? void 0 : _element$props$style.width;
30
32
  columnsWidth.push(colWidth);
31
33
  }
32
34
  });
33
35
  }
34
36
  return columnsWidth;
35
37
  };
36
- var columnsCount = 0;
37
- var countColumnsFromChildren = function countColumnsFromChildren(element) {
38
+ var countColumnsFromChildren = function countColumnsFromChildren(element, columnsCount) {
39
+ var count = columnsCount;
38
40
  if ( /*#__PURE__*/(0, _react.isValidElement)(element)) {
39
- var _element$props;
40
- if (_lodash.default.isArray(element === null || element === void 0 ? void 0 : (_element$props = element.props) === null || _element$props === void 0 ? void 0 : _element$props.children)) {
41
+ var _element$props2;
42
+ if (_lodash.default.isArray(element === null || element === void 0 ? void 0 : (_element$props2 = element.props) === null || _element$props2 === void 0 ? void 0 : _element$props2.children)) {
41
43
  var currentElement = element.props;
42
44
  currentElement.children.forEach(function (child) {
43
- return countColumnsFromChildren(child);
45
+ return countColumnsFromChildren(child, count);
44
46
  });
45
47
  } else if (element) {
46
- columnsCount += 1;
48
+ count.current += 1;
47
49
  }
48
50
  } else if (_lodash.default.isArray(element) && element.length > 0) {
49
51
  element.forEach(function (child) {
50
- return countColumnsFromChildren(child);
52
+ return countColumnsFromChildren(child, count);
51
53
  });
52
54
  }
53
55
  };
54
- var getColumnsCount = function getColumnsCount(children) {
56
+ var getColumnsCount = function getColumnsCount(children, columnsCount) {
55
57
  if (_lodash.default.isArray(children) && children.length > 0 && children[0].props) {
56
- countColumnsFromChildren(children[0].props.children);
58
+ countColumnsFromChildren(children[0].props.children, columnsCount);
57
59
  } else if ( /*#__PURE__*/(0, _react.isValidElement)(children) && children.props && children.props.children) {
58
- countColumnsFromChildren(children.props.children);
60
+ countColumnsFromChildren(children.props.children, columnsCount);
59
61
  }
60
- return columnsCount;
62
+ return columnsCount.current;
61
63
  };
62
64
  var Header = function Header(_ref) {
63
65
  var customClass = _ref.customClass,
@@ -67,10 +69,11 @@ var Header = function Header(_ref) {
67
69
  bodyScrollable = _useContext.bodyScrollable,
68
70
  handlerSetColumnsWidth = _useContext.handlerSetColumnsWidth,
69
71
  handlerSetColumnsCount = _useContext.handlerSetColumnsCount;
72
+ var columnsCount = (0, _react.useRef)(0);
70
73
  (0, _react.useEffect)(function () {
71
74
  if (children && handlerSetColumnsWidth && handlerSetColumnsCount) {
72
75
  handlerSetColumnsWidth(getColumnsWidth(children));
73
- handlerSetColumnsCount(getColumnsCount(children));
76
+ handlerSetColumnsCount(getColumnsCount(children, columnsCount));
74
77
  }
75
78
  }, []);
76
79
  return bodyScrollable ? /*#__PURE__*/_react.default.createElement("div", {
@@ -122,6 +122,7 @@ var Table = function Table(props) {
122
122
  handlerSetColumnsWidth: function handlerSetColumnsWidth(widths) {
123
123
  if (!_lodash.default.isEmpty(widths) && _lodash.default.isEmpty(columnsWidth)) setColumnsWidth(widths);
124
124
  },
125
+ columnsWidth: columnsWidth,
125
126
  handlerSetColumnsCount: function handlerSetColumnsCount(count) {
126
127
  return setColumnsCount(count);
127
128
  }
@@ -64,8 +64,10 @@ interface ITableContext {
64
64
  vertical?: boolean;
65
65
  skeletonize?: boolean;
66
66
  skeletonInHeader?: boolean;
67
+ skeletonHeight?: number;
67
68
  strict?: boolean;
68
69
  columnsCount?: number;
70
+ columnsWidth?: string[] | number[];
69
71
  handleSelectRow?: (rowId: SetStateAction<string | undefined>) => void;
70
72
  handleTableColClick?: () => void;
71
73
  handleTableRowClick?: (e: MouseEvent, dataId?: number | string) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "linear-react-components-ui",
3
- "version": "1.0.10-rc.2",
3
+ "version": "1.0.10-rc.3",
4
4
  "description": "Linear Sistemas ReactJs Components",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib/index.cjs",
@@ -1,133 +0,0 @@
1
- "use strict";
2
-
3
- var _react = _interopRequireDefault(require("react"));
4
-
5
- require("babel-polyfill");
6
-
7
- require("@testing-library/jest-dom");
8
-
9
- var _react2 = require("@testing-library/react");
10
-
11
- var _Message = _interopRequireDefault(require("./Message"));
12
-
13
- var _icons = _interopRequireDefault(require("../icons"));
14
-
15
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16
-
17
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
18
-
19
- function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
20
-
21
- function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
22
-
23
- var mockAlert = function mockAlert(props) {
24
- return /*#__PURE__*/_react.default.createElement(_Message.default, _extends({
25
- id: 3,
26
- message: "Alerta",
27
- position: "rightTop",
28
- closeButton: true,
29
- customClass: "mock-alert",
30
- timeout: 500
31
- }, props));
32
- };
33
-
34
- describe('Alert', function () {
35
- describe('Message', function () {
36
- it('should render correctly', function () {
37
- var mockHandleClose = jest.fn();
38
-
39
- var _render = (0, _react2.render)(mockAlert({
40
- handleClose: mockHandleClose
41
- })),
42
- container = _render.container;
43
-
44
- expect(container.firstChild).toBeTruthy();
45
- expect(container.firstChild).toHaveTextContent('Alerta');
46
- });
47
- it('should close with timeout 500ms', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
48
- var mockHandleClose;
49
- return regeneratorRuntime.wrap(function _callee$(_context) {
50
- while (1) {
51
- switch (_context.prev = _context.next) {
52
- case 0:
53
- mockHandleClose = jest.fn();
54
- (0, _react2.render)(mockAlert({
55
- handleClose: mockHandleClose
56
- }));
57
- _context.next = 4;
58
- return (0, _react2.waitFor)(function () {
59
- return expect(mockHandleClose).toBeCalledTimes(1);
60
- });
61
-
62
- case 4:
63
- case "end":
64
- return _context.stop();
65
- }
66
- }
67
- }, _callee);
68
- })));
69
- it('should apply custom class', function () {
70
- var mockHandleClose = jest.fn();
71
-
72
- var _render2 = (0, _react2.render)(mockAlert({
73
- handleClose: mockHandleClose
74
- })),
75
- container = _render2.container;
76
-
77
- expect(container.firstChild).toHaveClass('mock-alert');
78
- });
79
- it('should render icon', function () {
80
- var mockHandleClose = jest.fn();
81
-
82
- var _render3 = (0, _react2.render)(mockAlert({
83
- handleClose: mockHandleClose,
84
- icon: /*#__PURE__*/_react.default.createElement(_icons.default, {
85
- name: "user"
86
- })
87
- })),
88
- container = _render3.container,
89
- getByTestId = _render3.getByTestId;
90
-
91
- expect(container.querySelector('.-icon')).toContainElement(getByTestId('icon'));
92
- });
93
- it('should render icon by iconName', function () {
94
- var mockHandleClose = jest.fn();
95
-
96
- var _render4 = (0, _react2.render)(mockAlert({
97
- handleClose: mockHandleClose,
98
- iconName: 'user'
99
- })),
100
- container = _render4.container,
101
- getByTestId = _render4.getByTestId;
102
-
103
- expect(container.querySelector('.-icon')).toContainElement(getByTestId('icon'));
104
- });
105
- it('should change icon color', function () {
106
- var mockHandleClose = jest.fn();
107
-
108
- var _render5 = (0, _react2.render)(mockAlert({
109
- handleClose: mockHandleClose,
110
- iconName: 'user',
111
- color: 'red'
112
- })),
113
- getByTestId = _render5.getByTestId;
114
-
115
- expect(getByTestId('icon')).toHaveAttribute('fill', 'red');
116
- });
117
- it('should fire event on click', function () {
118
- var mockHandleClose = jest.fn();
119
-
120
- var _render6 = (0, _react2.render)(mockAlert({
121
- handleClose: mockHandleClose
122
- })),
123
- container = _render6.container,
124
- getByRole = _render6.getByRole;
125
-
126
- _react2.fireEvent.click(getByRole('button'));
127
-
128
- expect(container.querySelector('.close')).toBeInTheDocument();
129
- expect(container.querySelector('.close-button')).toBeInTheDocument();
130
- expect(mockHandleClose).toBeCalledTimes(1);
131
- });
132
- });
133
- });