linear-react-components-ui 1.0.11-beta.3 → 1.0.12-beta.1
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/lib/alerts/alert.spec.js +55 -32
- package/lib/avatar/avatar.spec.js +74 -42
- package/lib/badge/badge.spec.js +52 -30
- package/lib/buttons/SpinnerLoading.js +230 -0
- package/lib/buttons/buttons.spec.js +210 -136
- package/lib/calendar/calendar.spec.js +63 -32
- package/lib/checkbox/checkbox.spec.js +78 -37
- package/lib/dialog/dialog.spec.js +153 -80
- package/lib/drawer/Drawer.spec.js +95 -52
- package/lib/dropdown/dropdown.spec.js +58 -34
- package/lib/fieldset/fieldset.spec.js +123 -77
- package/lib/form/FieldNumber.js +6 -2
- package/lib/form/form.spec.js +81 -35
- package/lib/gridlayout/gridLayout.spec.js +70 -43
- package/lib/icons/helper.d.ts +0 -8
- package/lib/icons/helper.js +0 -8
- package/lib/icons/icons.spec.js +36 -20
- package/lib/inputs/base/base.spec.js +291 -176
- package/lib/inputs/base/index.js +1 -0
- package/lib/inputs/color/color_input.spec.js +67 -33
- package/lib/inputs/date/date.spec.js +156 -75
- package/lib/inputs/mask/helpers.js +1 -1
- package/lib/inputs/mask/input_mask.spec.js +290 -177
- package/lib/inputs/number/numberfield.spec.js +83 -42
- package/lib/inputs/search/search_input.spec.js +86 -46
- package/lib/inputs/select/select.spec.js +182 -127
- package/lib/inputs/text/textfield.spec.js +83 -42
- package/lib/inputs/textarea/index.js +1 -1
- package/lib/inputs/textarea/textarea.spec.js +27 -14
- package/lib/labelMessages/labelMessages.spec.js +61 -28
- package/lib/labels/label.spec.js +68 -41
- package/lib/list/list.spec.js +358 -211
- package/lib/menus/float/float-menu.spec.js +61 -27
- package/lib/menus/sidenav/sidenav.spec.js +78 -29
- package/lib/panel/panel.spec.js +106 -69
- package/lib/popover/popover.spec.js +70 -40
- package/lib/progress/progress.spec.js +48 -32
- package/lib/radio/radio.spec.js +59 -25
- package/lib/spinner/spinner.spec.js +65 -43
- package/lib/split/split.spec.js +76 -51
- package/lib/table/table.spec.js +149 -94
- package/lib/tabs/tabs.spec.js +158 -95
- package/lib/toolbar/toolbar.spec.js +182 -134
- package/lib/tooltip/tooltip.spec.js +51 -24
- package/lib/treeview/treeview.spec.js +86 -49
- package/lib/uitour/uitour.spec.js +56 -25
- package/package.json +1 -1
|
@@ -1,29 +1,38 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
3
|
var _react = _interopRequireDefault(require("react"));
|
|
4
|
+
|
|
5
5
|
var _react2 = require("@testing-library/react");
|
|
6
|
+
|
|
6
7
|
require("@testing-library/jest-dom/extend-expect");
|
|
8
|
+
|
|
7
9
|
require("babel-polyfill");
|
|
10
|
+
|
|
8
11
|
var _DefaultButton = _interopRequireDefault(require("../buttons/DefaultButton"));
|
|
12
|
+
|
|
9
13
|
var _ = _interopRequireDefault(require("."));
|
|
14
|
+
|
|
10
15
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
-
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var method = delegate.iterator[context.method]; if (undefined === method) { if (context.delegate = null, "throw" === context.method) { if (delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel; context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method"); } return ContinueSentinel; } var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
16
|
+
|
|
12
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
|
+
|
|
13
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); }); }; }
|
|
14
|
-
|
|
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
|
+
|
|
15
23
|
describe('Tooltip', function () {
|
|
16
24
|
var tooltipTestId = 'tooltip-component';
|
|
17
25
|
describe('Default Tooltip', function () {
|
|
18
26
|
var mockHandler = jest.fn();
|
|
27
|
+
|
|
19
28
|
var mockToolTip = /*#__PURE__*/_react.default.createElement(_.default, {
|
|
20
|
-
text: "Tooltip"
|
|
21
|
-
// eslint-disable-next-line react/style-prop-object
|
|
29
|
+
text: "Tooltip" // eslint-disable-next-line react/style-prop-object
|
|
22
30
|
,
|
|
23
31
|
style: "width: 100px;",
|
|
24
32
|
className: "right",
|
|
25
33
|
handlerSetDimensions: mockHandler
|
|
26
34
|
});
|
|
35
|
+
|
|
27
36
|
it('should render Tooltip correctly', function () {
|
|
28
37
|
(0, _react2.render)(mockToolTip);
|
|
29
38
|
expect(_react2.screen.getByTestId(tooltipTestId)).toBeInTheDocument();
|
|
@@ -42,17 +51,20 @@ describe('Tooltip', function () {
|
|
|
42
51
|
label: "Tooltip Label"
|
|
43
52
|
}, props));
|
|
44
53
|
};
|
|
54
|
+
|
|
45
55
|
var showTooltip = /*#__PURE__*/function () {
|
|
46
|
-
var _ref = _asyncToGenerator( /*#__PURE__*/
|
|
47
|
-
return
|
|
56
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(container) {
|
|
57
|
+
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
48
58
|
while (1) {
|
|
49
59
|
switch (_context.prev = _context.next) {
|
|
50
60
|
case 0:
|
|
51
61
|
_react2.fireEvent.mouseOver(container.firstChild);
|
|
62
|
+
|
|
52
63
|
_context.next = 3;
|
|
53
64
|
return (0, _react2.waitFor)(function () {
|
|
54
65
|
return _react2.screen.getByTestId(tooltipTestId);
|
|
55
66
|
});
|
|
67
|
+
|
|
56
68
|
case 3:
|
|
57
69
|
case "end":
|
|
58
70
|
return _context.stop();
|
|
@@ -60,10 +72,12 @@ describe('Tooltip', function () {
|
|
|
60
72
|
}
|
|
61
73
|
}, _callee);
|
|
62
74
|
}));
|
|
75
|
+
|
|
63
76
|
return function showTooltip(_x) {
|
|
64
77
|
return _ref.apply(this, arguments);
|
|
65
78
|
};
|
|
66
79
|
}();
|
|
80
|
+
|
|
67
81
|
beforeEach(function () {
|
|
68
82
|
Element.prototype.getBoundingClientRect = jest.fn(function () {
|
|
69
83
|
return {
|
|
@@ -72,31 +86,32 @@ describe('Tooltip', function () {
|
|
|
72
86
|
top: 200,
|
|
73
87
|
left: 200,
|
|
74
88
|
bottom: 0,
|
|
75
|
-
right: 0
|
|
76
|
-
x: 0,
|
|
77
|
-
y: 0,
|
|
78
|
-
toJSON: function toJSON() {}
|
|
89
|
+
right: 0
|
|
79
90
|
};
|
|
80
91
|
});
|
|
81
92
|
});
|
|
82
93
|
it('should button render correctly', function () {
|
|
83
|
-
var _render = (0, _react2.render)(mockToolTip(
|
|
84
|
-
|
|
94
|
+
var _render = (0, _react2.render)(mockToolTip()),
|
|
95
|
+
container = _render.container;
|
|
96
|
+
|
|
85
97
|
expect(container.firstChild).toHaveTextContent('Tooltip Label');
|
|
86
98
|
});
|
|
87
|
-
it('should show tooltip', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/
|
|
99
|
+
it('should show tooltip', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
|
|
88
100
|
var _render2, container;
|
|
89
|
-
|
|
101
|
+
|
|
102
|
+
return regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
90
103
|
while (1) {
|
|
91
104
|
switch (_context2.prev = _context2.next) {
|
|
92
105
|
case 0:
|
|
93
|
-
_render2 = (0, _react2.render)(mockToolTip(
|
|
106
|
+
_render2 = (0, _react2.render)(mockToolTip()), container = _render2.container;
|
|
94
107
|
_context2.next = 3;
|
|
95
108
|
return showTooltip(container);
|
|
109
|
+
|
|
96
110
|
case 3:
|
|
97
111
|
expect(_react2.screen.getByTestId(tooltipTestId)).toBeInTheDocument();
|
|
98
112
|
expect(_react2.screen.getByTestId(tooltipTestId)).toHaveTextContent('Tooltip');
|
|
99
113
|
expect(_react2.screen.getByTestId(tooltipTestId)).toHaveClass('tooltip-component');
|
|
114
|
+
|
|
100
115
|
case 6:
|
|
101
116
|
case "end":
|
|
102
117
|
return _context2.stop();
|
|
@@ -104,9 +119,10 @@ describe('Tooltip', function () {
|
|
|
104
119
|
}
|
|
105
120
|
}, _callee2);
|
|
106
121
|
})));
|
|
107
|
-
it('should tooltip render in top', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/
|
|
122
|
+
it('should tooltip render in top', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3() {
|
|
108
123
|
var _render3, container;
|
|
109
|
-
|
|
124
|
+
|
|
125
|
+
return regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
110
126
|
while (1) {
|
|
111
127
|
switch (_context3.prev = _context3.next) {
|
|
112
128
|
case 0:
|
|
@@ -115,8 +131,10 @@ describe('Tooltip', function () {
|
|
|
115
131
|
})), container = _render3.container;
|
|
116
132
|
_context3.next = 3;
|
|
117
133
|
return showTooltip(container);
|
|
134
|
+
|
|
118
135
|
case 3:
|
|
119
136
|
expect(_react2.screen.getByTestId(tooltipTestId)).toHaveClass('top');
|
|
137
|
+
|
|
120
138
|
case 4:
|
|
121
139
|
case "end":
|
|
122
140
|
return _context3.stop();
|
|
@@ -124,9 +142,10 @@ describe('Tooltip', function () {
|
|
|
124
142
|
}
|
|
125
143
|
}, _callee3);
|
|
126
144
|
})));
|
|
127
|
-
it('should tooltip render in bottom', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/
|
|
145
|
+
it('should tooltip render in bottom', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4() {
|
|
128
146
|
var _render4, container;
|
|
129
|
-
|
|
147
|
+
|
|
148
|
+
return regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
130
149
|
while (1) {
|
|
131
150
|
switch (_context4.prev = _context4.next) {
|
|
132
151
|
case 0:
|
|
@@ -135,8 +154,10 @@ describe('Tooltip', function () {
|
|
|
135
154
|
})), container = _render4.container;
|
|
136
155
|
_context4.next = 3;
|
|
137
156
|
return showTooltip(container);
|
|
157
|
+
|
|
138
158
|
case 3:
|
|
139
159
|
expect(_react2.screen.getByTestId(tooltipTestId)).toHaveClass('bottom');
|
|
160
|
+
|
|
140
161
|
case 4:
|
|
141
162
|
case "end":
|
|
142
163
|
return _context4.stop();
|
|
@@ -144,9 +165,10 @@ describe('Tooltip', function () {
|
|
|
144
165
|
}
|
|
145
166
|
}, _callee4);
|
|
146
167
|
})));
|
|
147
|
-
it('should tooltip render in left', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/
|
|
168
|
+
it('should tooltip render in left', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee5() {
|
|
148
169
|
var _render5, container;
|
|
149
|
-
|
|
170
|
+
|
|
171
|
+
return regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
150
172
|
while (1) {
|
|
151
173
|
switch (_context5.prev = _context5.next) {
|
|
152
174
|
case 0:
|
|
@@ -155,8 +177,10 @@ describe('Tooltip', function () {
|
|
|
155
177
|
})), container = _render5.container;
|
|
156
178
|
_context5.next = 3;
|
|
157
179
|
return showTooltip(container);
|
|
180
|
+
|
|
158
181
|
case 3:
|
|
159
182
|
expect(_react2.screen.getByTestId(tooltipTestId)).toHaveClass('left');
|
|
183
|
+
|
|
160
184
|
case 4:
|
|
161
185
|
case "end":
|
|
162
186
|
return _context5.stop();
|
|
@@ -164,9 +188,10 @@ describe('Tooltip', function () {
|
|
|
164
188
|
}
|
|
165
189
|
}, _callee5);
|
|
166
190
|
})));
|
|
167
|
-
it('should tooltip render in right', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/
|
|
191
|
+
it('should tooltip render in right', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee6() {
|
|
168
192
|
var _render6, container;
|
|
169
|
-
|
|
193
|
+
|
|
194
|
+
return regeneratorRuntime.wrap(function _callee6$(_context6) {
|
|
170
195
|
while (1) {
|
|
171
196
|
switch (_context6.prev = _context6.next) {
|
|
172
197
|
case 0:
|
|
@@ -175,8 +200,10 @@ describe('Tooltip', function () {
|
|
|
175
200
|
})), container = _render6.container;
|
|
176
201
|
_context6.next = 3;
|
|
177
202
|
return showTooltip(container);
|
|
203
|
+
|
|
178
204
|
case 3:
|
|
179
205
|
expect(_react2.screen.getByTestId(tooltipTestId)).toHaveClass('right');
|
|
206
|
+
|
|
180
207
|
case 4:
|
|
181
208
|
case "end":
|
|
182
209
|
return _context6.stop();
|
|
@@ -1,16 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
3
|
var _react = require("@testing-library/react");
|
|
4
|
+
|
|
5
5
|
var _react2 = _interopRequireDefault(require("react"));
|
|
6
|
+
|
|
6
7
|
require("@testing-library/jest-dom");
|
|
8
|
+
|
|
7
9
|
require("babel-polyfill");
|
|
10
|
+
|
|
8
11
|
var _ = _interopRequireDefault(require("."));
|
|
12
|
+
|
|
9
13
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
-
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var method = delegate.iterator[context.method]; if (undefined === method) { if (context.delegate = null, "throw" === context.method) { if (delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel; context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method"); } return ContinueSentinel; } var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
14
|
+
|
|
11
15
|
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); } }
|
|
16
|
+
|
|
12
17
|
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); }); }; }
|
|
13
|
-
|
|
18
|
+
|
|
19
|
+
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); }
|
|
20
|
+
|
|
14
21
|
var dataMock = {
|
|
15
22
|
id: 1,
|
|
16
23
|
titulo: 'SG Linear',
|
|
@@ -38,8 +45,7 @@ var dataMock = {
|
|
|
38
45
|
codigo: 'Editar',
|
|
39
46
|
itens: [{
|
|
40
47
|
titulo: 'Editar permissão ERP',
|
|
41
|
-
codigo: 'Editar permissão ERP'
|
|
42
|
-
itens: []
|
|
48
|
+
codigo: 'Editar permissão ERP'
|
|
43
49
|
}]
|
|
44
50
|
}]
|
|
45
51
|
}]
|
|
@@ -55,11 +61,11 @@ var dataMock = {
|
|
|
55
61
|
itens: [{
|
|
56
62
|
id: 5,
|
|
57
63
|
titulo: 'Empresas',
|
|
58
|
-
codigo: 'empresas'
|
|
59
|
-
itens: []
|
|
64
|
+
codigo: 'empresas'
|
|
60
65
|
}]
|
|
61
66
|
}]
|
|
62
67
|
};
|
|
68
|
+
|
|
63
69
|
var treeviewRenderMock = function treeviewRenderMock(props) {
|
|
64
70
|
return /*#__PURE__*/_react2.default.createElement(_.default, _extends({
|
|
65
71
|
data: dataMock,
|
|
@@ -68,38 +74,47 @@ var treeviewRenderMock = function treeviewRenderMock(props) {
|
|
|
68
74
|
parentPropName: "0"
|
|
69
75
|
}, props));
|
|
70
76
|
};
|
|
77
|
+
|
|
71
78
|
describe('Treeview', function () {
|
|
72
79
|
describe('Default', function () {
|
|
73
80
|
it('should render', function () {
|
|
74
81
|
var _render = (0, _react.render)(treeviewRenderMock()),
|
|
75
|
-
|
|
82
|
+
container = _render.container;
|
|
83
|
+
|
|
76
84
|
expect(container.firstChild).toBeTruthy();
|
|
77
85
|
});
|
|
78
86
|
it('should have start node visible', function () {
|
|
79
87
|
var _render2 = (0, _react.render)(treeviewRenderMock()),
|
|
80
|
-
|
|
88
|
+
queryByText = _render2.queryByText;
|
|
89
|
+
|
|
81
90
|
expect(queryByText(dataMock.titulo)).toBeTruthy();
|
|
82
91
|
});
|
|
83
92
|
it('should not have second node visible', function () {
|
|
84
93
|
var _render3 = (0, _react.render)(treeviewRenderMock()),
|
|
85
|
-
|
|
94
|
+
queryByText = _render3.queryByText;
|
|
95
|
+
|
|
86
96
|
expect(queryByText(dataMock.itens[0].titulo)).not.toBeTruthy();
|
|
87
97
|
});
|
|
88
|
-
it('should open on click', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/
|
|
98
|
+
it('should open on click', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
|
|
89
99
|
var _render4, container, queryByText;
|
|
90
|
-
|
|
100
|
+
|
|
101
|
+
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
91
102
|
while (1) {
|
|
92
103
|
switch (_context.prev = _context.next) {
|
|
93
104
|
case 0:
|
|
94
105
|
_render4 = (0, _react.render)(treeviewRenderMock()), container = _render4.container, queryByText = _render4.queryByText;
|
|
106
|
+
|
|
95
107
|
_react.fireEvent.click(container.querySelector('.treeviewitem .opencloseicon'));
|
|
108
|
+
|
|
96
109
|
_context.next = 4;
|
|
97
110
|
return (0, _react.waitFor)(function () {
|
|
98
111
|
return queryByText(dataMock.itens[0].titulo);
|
|
99
112
|
});
|
|
113
|
+
|
|
100
114
|
case 4:
|
|
101
115
|
expect(queryByText(dataMock.itens[0].titulo)).toBeTruthy();
|
|
102
116
|
expect(queryByText(dataMock.itens[1].titulo)).toBeTruthy();
|
|
117
|
+
|
|
103
118
|
case 6:
|
|
104
119
|
case "end":
|
|
105
120
|
return _context.stop();
|
|
@@ -107,42 +122,54 @@ describe('Treeview', function () {
|
|
|
107
122
|
}
|
|
108
123
|
}, _callee);
|
|
109
124
|
})));
|
|
110
|
-
it('should open all layers', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/
|
|
125
|
+
it('should open all layers', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
|
|
111
126
|
var _render5, container, queryByText;
|
|
112
|
-
|
|
127
|
+
|
|
128
|
+
return regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
113
129
|
while (1) {
|
|
114
130
|
switch (_context2.prev = _context2.next) {
|
|
115
131
|
case 0:
|
|
116
132
|
_render5 = (0, _react.render)(treeviewRenderMock()), container = _render5.container, queryByText = _render5.queryByText;
|
|
133
|
+
|
|
117
134
|
_react.fireEvent.click(container.querySelector('.treeviewitem .opencloseicon'));
|
|
135
|
+
|
|
118
136
|
_context2.next = 4;
|
|
119
137
|
return (0, _react.waitFor)(function () {
|
|
120
138
|
return queryByText(dataMock.itens[0].titulo);
|
|
121
139
|
});
|
|
140
|
+
|
|
122
141
|
case 4:
|
|
123
142
|
_react.fireEvent.click(container.querySelectorAll('.treeviewitem .opencloseicon')[1]);
|
|
143
|
+
|
|
124
144
|
_context2.next = 7;
|
|
125
145
|
return (0, _react.waitFor)(function () {
|
|
126
146
|
return queryByText(dataMock.itens[0].itens[0].titulo);
|
|
127
147
|
});
|
|
148
|
+
|
|
128
149
|
case 7:
|
|
129
150
|
_react.fireEvent.click(container.querySelectorAll('.treeviewitem .opencloseicon')[2]);
|
|
151
|
+
|
|
130
152
|
_context2.next = 10;
|
|
131
153
|
return (0, _react.waitFor)(function () {
|
|
132
154
|
return queryByText(dataMock.itens[0].itens[0].itens[0].titulo);
|
|
133
155
|
});
|
|
156
|
+
|
|
134
157
|
case 10:
|
|
135
158
|
_react.fireEvent.click(container.querySelectorAll('.treeviewitem .opencloseicon')[3]);
|
|
159
|
+
|
|
136
160
|
_context2.next = 13;
|
|
137
161
|
return (0, _react.waitFor)(function () {
|
|
138
162
|
return queryByText(dataMock.itens[0].itens[0].itens[0].itens[0].titulo);
|
|
139
163
|
});
|
|
164
|
+
|
|
140
165
|
case 13:
|
|
141
166
|
_react.fireEvent.click(container.querySelectorAll('.treeviewitem .opencloseicon')[4]);
|
|
167
|
+
|
|
142
168
|
_context2.next = 16;
|
|
143
169
|
return (0, _react.waitFor)(function () {
|
|
144
170
|
return queryByText(dataMock.itens[1].itens[0].titulo);
|
|
145
171
|
});
|
|
172
|
+
|
|
146
173
|
case 16:
|
|
147
174
|
expect(queryByText(dataMock.itens[0].titulo)).toBeTruthy();
|
|
148
175
|
expect(queryByText(dataMock.itens[0].itens[0].titulo)).toBeTruthy();
|
|
@@ -150,6 +177,7 @@ describe('Treeview', function () {
|
|
|
150
177
|
expect(queryByText(dataMock.itens[0].itens[0].itens[0].itens[0].titulo)).toBeTruthy();
|
|
151
178
|
expect(queryByText(dataMock.itens[1].titulo)).toBeTruthy();
|
|
152
179
|
expect(queryByText(dataMock.itens[1].itens[0].titulo)).toBeTruthy();
|
|
180
|
+
|
|
153
181
|
case 22:
|
|
154
182
|
case "end":
|
|
155
183
|
return _context2.stop();
|
|
@@ -159,44 +187,51 @@ describe('Treeview', function () {
|
|
|
159
187
|
})));
|
|
160
188
|
it('should render checkbox', function () {
|
|
161
189
|
var _render6 = (0, _react.render)(treeviewRenderMock({
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
190
|
+
showCheckBox: true
|
|
191
|
+
})),
|
|
192
|
+
container = _render6.container;
|
|
193
|
+
|
|
165
194
|
expect(container.querySelector('.checkbox-component')).toBeTruthy();
|
|
166
195
|
});
|
|
167
196
|
it('should call onSelectedIdsChange callback', function () {
|
|
168
197
|
var mockCallback = jest.fn(function (x) {
|
|
169
198
|
return x;
|
|
170
199
|
});
|
|
200
|
+
|
|
171
201
|
var _render7 = (0, _react.render)(treeviewRenderMock({
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
202
|
+
showCheckBox: true,
|
|
203
|
+
onSelectedIdsChange: mockCallback
|
|
204
|
+
})),
|
|
205
|
+
container = _render7.container;
|
|
206
|
+
|
|
176
207
|
_react.fireEvent.click(container.querySelector('.checkbox-component'));
|
|
208
|
+
|
|
177
209
|
expect(mockCallback.mock.calls.length).toBe(1);
|
|
178
210
|
expect(mockCallback.mock.calls[0][0]).toStrictEqual([1]);
|
|
179
211
|
});
|
|
180
212
|
it('should control checkbox by selectedIds', function () {
|
|
181
213
|
var _render8 = (0, _react.render)(treeviewRenderMock({
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
214
|
+
showCheckBox: true,
|
|
215
|
+
selectedIds: [1]
|
|
216
|
+
})),
|
|
217
|
+
container = _render8.container;
|
|
218
|
+
|
|
186
219
|
expect(container.querySelector('.checkbox-component input[type=checkbox]')).toBeChecked();
|
|
187
220
|
});
|
|
188
221
|
it('should start checkbox unchecked', function () {
|
|
189
222
|
var _render9 = (0, _react.render)(treeviewRenderMock({
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
223
|
+
showCheckBox: true
|
|
224
|
+
})),
|
|
225
|
+
container = _render9.container;
|
|
226
|
+
|
|
193
227
|
expect(container.querySelector('.checkbox-component input[type=checkbox]')).not.toBeChecked();
|
|
194
228
|
});
|
|
195
229
|
it('should start nodes open', function () {
|
|
196
230
|
var _render10 = (0, _react.render)(treeviewRenderMock({
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
231
|
+
startNodesOpened: true
|
|
232
|
+
})),
|
|
233
|
+
queryByText = _render10.queryByText;
|
|
234
|
+
|
|
200
235
|
expect(queryByText(dataMock.itens[0].titulo)).toBeTruthy();
|
|
201
236
|
expect(queryByText(dataMock.itens[0].itens[0].titulo)).toBeTruthy();
|
|
202
237
|
expect(queryByText(dataMock.itens[0].itens[0].itens[0].titulo)).toBeTruthy();
|
|
@@ -206,36 +241,38 @@ describe('Treeview', function () {
|
|
|
206
241
|
});
|
|
207
242
|
it('should apply customClass', function () {
|
|
208
243
|
var _render11 = (0, _react.render)(treeviewRenderMock({
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
244
|
+
customClass: 'customClass'
|
|
245
|
+
})),
|
|
246
|
+
container = _render11.container;
|
|
247
|
+
|
|
212
248
|
expect(container.firstChild).toHaveClass('customClass');
|
|
213
249
|
});
|
|
214
250
|
it('should apply style', function () {
|
|
215
251
|
var _render12 = (0, _react.render)(treeviewRenderMock({
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
252
|
+
styleForContainer: {
|
|
253
|
+
backgroundColor: '#000'
|
|
254
|
+
}
|
|
255
|
+
})),
|
|
256
|
+
container = _render12.container;
|
|
257
|
+
|
|
221
258
|
expect(container.querySelector('ul')).toHaveStyle('background-color: #000');
|
|
222
259
|
});
|
|
223
260
|
it('should apply idsInLoading', function () {
|
|
224
|
-
var _container$querySelec;
|
|
225
261
|
var _render13 = (0, _react.render)(treeviewRenderMock({
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
262
|
+
idsInLoading: [1]
|
|
263
|
+
})),
|
|
264
|
+
container = _render13.container;
|
|
265
|
+
|
|
266
|
+
var li = container.querySelector('li').firstChild;
|
|
230
267
|
expect(li.firstChild).toHaveClass('spinnerloading');
|
|
231
268
|
});
|
|
232
269
|
it('should apply selectedNodeId', function () {
|
|
233
|
-
var _container$querySelec2;
|
|
234
270
|
var _render14 = (0, _react.render)(treeviewRenderMock({
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
271
|
+
selectedNodeId: 1
|
|
272
|
+
})),
|
|
273
|
+
container = _render14.container;
|
|
274
|
+
|
|
275
|
+
var filhosLi = container.querySelector('li').children;
|
|
239
276
|
expect(filhosLi[1]).toHaveStyle('background-color: rgb(209, 209, 209)');
|
|
240
277
|
});
|
|
241
278
|
});
|