jqtree 1.6.3 → 1.7.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/.github/workflows/ci.yml +15 -21
- package/.github/workflows/codeql-analysis.yml +2 -2
- package/README.md +1 -1
- package/bower.json +10 -3
- package/config/production +2 -2
- package/config/{rollup.config.js → rollup.config.mjs} +3 -8
- package/docs/Gemfile.lock +34 -37
- package/docs/_config.yml +1 -1
- package/docs/_entries/10_changelog.md +13 -0
- package/docs/_entries/93_getnextnode.md +4 -1
- package/docs/_entries/{95_getpreviousnode.md → 95_getnextvisiblenode.md} +1 -1
- package/docs/_entries/96_getpreviousnode.md +0 -0
- package/docs/_entries/98_getpreviousvisiblenode.md +14 -0
- package/docs/package.json +7 -7
- package/docs/pnpm-lock.yaml +413 -265
- package/docs/static/bower.json +2 -2
- package/docs/static/bower_components/fontawesome/css/all.min.css +6 -2
- package/docs/static/bower_components/fontawesome/webfonts/fa-brands-400.ttf +0 -0
- package/docs/static/bower_components/fontawesome/webfonts/fa-brands-400.woff2 +0 -0
- package/docs/static/bower_components/fontawesome/webfonts/fa-regular-400.ttf +0 -0
- package/docs/static/bower_components/fontawesome/webfonts/fa-regular-400.woff2 +0 -0
- package/docs/static/bower_components/fontawesome/webfonts/fa-solid-900.ttf +0 -0
- package/docs/static/bower_components/fontawesome/webfonts/fa-solid-900.woff2 +0 -0
- package/docs/static/bower_components/fontawesome/webfonts/fa-v4compatibility.ttf +0 -0
- package/docs/static/bower_components/fontawesome/webfonts/fa-v4compatibility.woff2 +0 -0
- package/docs/static/bower_components/jquery/dist/jquery.js +944 -1121
- package/docs/static/bower_components/jquery/dist/jquery.min.js +2 -2
- package/docs/static/documentation.css +181 -159
- package/docs/static/example.css +0 -1
- package/docs/tree.jquery.js +3 -3
- package/lib/dataLoader.js +5 -31
- package/lib/dragAndDropHandler.js +40 -142
- package/lib/elementsRenderer.js +52 -72
- package/lib/keyHandler.js +8 -32
- package/lib/mouse.widget.js +24 -74
- package/lib/node.js +72 -134
- package/lib/nodeElement.js +24 -84
- package/lib/playwright/coverage.js +58 -97
- package/lib/playwright/playwright.test.js +148 -210
- package/lib/playwright/testUtils.js +116 -182
- package/lib/saveStateHandler.js +13 -62
- package/lib/scrollHandler.js +24 -77
- package/lib/selectNodeHandler.js +6 -25
- package/lib/simple.widget.js +20 -53
- package/lib/test/jqTree/accessibility.test.js +37 -0
- package/lib/test/jqTree/create.test.js +0 -4
- package/lib/test/jqTree/events.test.js +73 -84
- package/lib/test/jqTree/keyboard.test.js +0 -6
- package/lib/test/jqTree/loadOnDemand.test.js +84 -121
- package/lib/test/jqTree/methods.test.js +107 -150
- package/lib/test/jqTree/options.test.js +32 -54
- package/lib/test/node.test.js +134 -76
- package/lib/test/nodeUtil.test.js +0 -1
- package/lib/test/support/jqTreeMatchers.js +4 -9
- package/lib/test/support/setupTests.js +0 -4
- package/lib/test/support/testUtil.js +2 -11
- package/lib/test/support/treeStructure.js +0 -6
- package/lib/test/util.test.js +0 -1
- package/lib/tree.jquery.js +28 -239
- package/lib/util.js +0 -6
- package/lib/version.js +1 -1
- package/package.json +44 -47
- package/src/dragAndDropHandler.ts +24 -10
- package/src/elementsRenderer.ts +49 -42
- package/src/jqtreeOptions.ts +3 -3
- package/src/keyHandler.ts +3 -3
- package/src/mouse.widget.ts +12 -0
- package/src/node.ts +52 -16
- package/src/nodeElement.ts +27 -21
- package/src/saveStateHandler.ts +1 -1
- package/src/scrollHandler.ts +6 -2
- package/src/selectNodeHandler.ts +1 -1
- package/src/simple.widget.ts +2 -0
- package/src/test/.eslintrc +3 -1
- package/src/test/jqTree/accessibility.test.ts +25 -0
- package/src/test/jqTree/events.test.ts +79 -93
- package/src/test/jqTree/methods.test.ts +1 -1
- package/src/test/node.test.ts +152 -58
- package/src/test/nodeUtil.test.ts +1 -1
- package/src/tree.jquery.ts +7 -6
- package/src/version.ts +1 -1
- package/tree.jquery.debug.js +297 -904
- package/tree.jquery.debug.js.map +1 -1
- package/tree.jquery.js +3 -3
- package/tree.jquery.js.map +1 -1
- package/tsconfig.json +1 -0
- package/docs/static/bower_components/fontawesome/webfonts/fa-brands-400.eot +0 -0
- package/docs/static/bower_components/fontawesome/webfonts/fa-brands-400.svg +0 -3717
- package/docs/static/bower_components/fontawesome/webfonts/fa-brands-400.woff +0 -0
- package/docs/static/bower_components/fontawesome/webfonts/fa-regular-400.eot +0 -0
- package/docs/static/bower_components/fontawesome/webfonts/fa-regular-400.svg +0 -801
- package/docs/static/bower_components/fontawesome/webfonts/fa-regular-400.woff +0 -0
- package/docs/static/bower_components/fontawesome/webfonts/fa-solid-900.eot +0 -0
- package/docs/static/bower_components/fontawesome/webfonts/fa-solid-900.svg +0 -5028
- package/docs/static/bower_components/fontawesome/webfonts/fa-solid-900.woff +0 -0
- /package/docs/_entries/{96_getprevioussibling.md → 97_getprevioussibling.md} +0 -0
- /package/docs/_entries/{97_parent.md → 99_parent.md} +0 -0
package/lib/simple.widget.js
CHANGED
|
@@ -4,62 +4,46 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports["default"] = void 0;
|
|
7
|
-
|
|
8
7
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
9
|
-
|
|
10
8
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
11
|
-
|
|
12
9
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
13
|
-
|
|
14
|
-
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
15
|
-
|
|
10
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
16
11
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
17
|
-
|
|
18
|
-
function
|
|
19
|
-
|
|
12
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
13
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
14
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
20
15
|
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); }
|
|
21
|
-
|
|
22
16
|
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
|
|
23
|
-
|
|
24
17
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
25
|
-
|
|
26
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
27
|
-
|
|
18
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
28
19
|
var _register = function register(widgetClass, widgetName) {
|
|
29
20
|
var getDataKey = function getDataKey() {
|
|
30
21
|
return "simple_widget_".concat(widgetName);
|
|
31
22
|
};
|
|
32
|
-
|
|
33
23
|
var getWidgetData = function getWidgetData(el, dataKey) {
|
|
34
24
|
var widget = jQuery.data(el, dataKey);
|
|
35
|
-
|
|
36
25
|
if (widget && widget instanceof SimpleWidget) {
|
|
37
26
|
return widget;
|
|
38
27
|
} else {
|
|
39
28
|
return null;
|
|
40
29
|
}
|
|
41
30
|
};
|
|
42
|
-
|
|
43
31
|
var createWidget = function createWidget($el, options) {
|
|
44
32
|
var dataKey = getDataKey();
|
|
45
|
-
|
|
46
33
|
var _iterator = _createForOfIteratorHelper($el.get()),
|
|
47
|
-
|
|
48
|
-
|
|
34
|
+
_step;
|
|
49
35
|
try {
|
|
50
36
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
51
37
|
var el = _step.value;
|
|
52
38
|
var existingWidget = getWidgetData(el, dataKey);
|
|
53
|
-
|
|
54
39
|
if (!existingWidget) {
|
|
55
40
|
var simpleWidgetClass = widgetClass;
|
|
56
41
|
var widget = new simpleWidgetClass(el, options);
|
|
57
|
-
|
|
58
42
|
if (!jQuery.data(el, dataKey)) {
|
|
59
43
|
jQuery.data(el, dataKey, widget);
|
|
60
|
-
}
|
|
61
|
-
|
|
44
|
+
}
|
|
62
45
|
|
|
46
|
+
// Call init after setting data, so we can call methods
|
|
63
47
|
widget.init();
|
|
64
48
|
}
|
|
65
49
|
}
|
|
@@ -68,25 +52,19 @@ var _register = function register(widgetClass, widgetName) {
|
|
|
68
52
|
} finally {
|
|
69
53
|
_iterator.f();
|
|
70
54
|
}
|
|
71
|
-
|
|
72
55
|
return $el;
|
|
73
56
|
};
|
|
74
|
-
|
|
75
57
|
var destroyWidget = function destroyWidget($el) {
|
|
76
58
|
var dataKey = getDataKey();
|
|
77
|
-
|
|
78
59
|
var _iterator2 = _createForOfIteratorHelper($el.get()),
|
|
79
|
-
|
|
80
|
-
|
|
60
|
+
_step2;
|
|
81
61
|
try {
|
|
82
62
|
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
83
63
|
var el = _step2.value;
|
|
84
64
|
var widget = getWidgetData(el, dataKey);
|
|
85
|
-
|
|
86
65
|
if (widget) {
|
|
87
66
|
widget.destroy();
|
|
88
67
|
}
|
|
89
|
-
|
|
90
68
|
jQuery.removeData(el, dataKey);
|
|
91
69
|
}
|
|
92
70
|
} catch (err) {
|
|
@@ -95,22 +73,17 @@ var _register = function register(widgetClass, widgetName) {
|
|
|
95
73
|
_iterator2.f();
|
|
96
74
|
}
|
|
97
75
|
};
|
|
98
|
-
|
|
99
76
|
var callFunction = function callFunction($el, functionName, args) {
|
|
100
77
|
var result = null;
|
|
101
|
-
|
|
102
78
|
var _iterator3 = _createForOfIteratorHelper($el.get()),
|
|
103
|
-
|
|
104
|
-
|
|
79
|
+
_step3;
|
|
105
80
|
try {
|
|
106
81
|
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
107
82
|
var el = _step3.value;
|
|
108
83
|
var widget = jQuery.data(el, getDataKey());
|
|
109
|
-
|
|
110
84
|
if (widget && widget instanceof SimpleWidget) {
|
|
111
85
|
var simpleWidget = widget;
|
|
112
86
|
var widgetFunction = simpleWidget[functionName];
|
|
113
|
-
|
|
114
87
|
if (widgetFunction && typeof widgetFunction === "function") {
|
|
115
88
|
result = widgetFunction.apply(widget, args);
|
|
116
89
|
}
|
|
@@ -121,11 +94,10 @@ var _register = function register(widgetClass, widgetName) {
|
|
|
121
94
|
} finally {
|
|
122
95
|
_iterator3.f();
|
|
123
96
|
}
|
|
124
|
-
|
|
125
97
|
return result;
|
|
126
|
-
};
|
|
127
|
-
|
|
98
|
+
};
|
|
128
99
|
|
|
100
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
129
101
|
jQuery.fn[widgetName] = function (argument1) {
|
|
130
102
|
if (!argument1) {
|
|
131
103
|
return createWidget(this, null);
|
|
@@ -134,7 +106,6 @@ var _register = function register(widgetClass, widgetName) {
|
|
|
134
106
|
return createWidget(this, options);
|
|
135
107
|
} else if (typeof argument1 === "string" && argument1[0] !== "_") {
|
|
136
108
|
var functionName = argument1;
|
|
137
|
-
|
|
138
109
|
if (functionName === "destroy") {
|
|
139
110
|
return destroyWidget(this);
|
|
140
111
|
} else if (functionName === "get_widget_class") {
|
|
@@ -143,27 +114,24 @@ var _register = function register(widgetClass, widgetName) {
|
|
|
143
114
|
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
144
115
|
args[_key - 1] = arguments[_key];
|
|
145
116
|
}
|
|
146
|
-
|
|
147
117
|
return callFunction(this, functionName, args);
|
|
148
118
|
}
|
|
119
|
+
} else {
|
|
120
|
+
return undefined;
|
|
149
121
|
}
|
|
150
122
|
};
|
|
151
123
|
};
|
|
152
|
-
|
|
153
124
|
var SimpleWidget = /*#__PURE__*/function () {
|
|
154
125
|
function SimpleWidget(el, options) {
|
|
155
126
|
_classCallCheck(this, SimpleWidget);
|
|
156
|
-
|
|
157
127
|
_defineProperty(this, "options", void 0);
|
|
158
|
-
|
|
159
128
|
_defineProperty(this, "$el", void 0);
|
|
129
|
+
this.$el = jQuery(el);
|
|
160
130
|
|
|
161
|
-
|
|
162
|
-
|
|
131
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
163
132
|
var defaults = this.constructor["defaults"];
|
|
164
133
|
this.options = _objectSpread(_objectSpread({}, defaults), options);
|
|
165
134
|
}
|
|
166
|
-
|
|
167
135
|
_createClass(SimpleWidget, [{
|
|
168
136
|
key: "destroy",
|
|
169
137
|
value: function destroy() {
|
|
@@ -171,11 +139,13 @@ var SimpleWidget = /*#__PURE__*/function () {
|
|
|
171
139
|
}
|
|
172
140
|
}, {
|
|
173
141
|
key: "init",
|
|
174
|
-
value: function init() {
|
|
142
|
+
value: function init() {
|
|
143
|
+
//
|
|
175
144
|
}
|
|
176
145
|
}, {
|
|
177
146
|
key: "deinit",
|
|
178
|
-
value: function deinit() {
|
|
147
|
+
value: function deinit() {
|
|
148
|
+
//
|
|
179
149
|
}
|
|
180
150
|
}], [{
|
|
181
151
|
key: "register",
|
|
@@ -183,10 +153,7 @@ var SimpleWidget = /*#__PURE__*/function () {
|
|
|
183
153
|
_register(widgetClass, widgetName);
|
|
184
154
|
}
|
|
185
155
|
}]);
|
|
186
|
-
|
|
187
156
|
return SimpleWidget;
|
|
188
157
|
}();
|
|
189
|
-
|
|
190
158
|
exports["default"] = SimpleWidget;
|
|
191
|
-
|
|
192
159
|
_defineProperty(SimpleWidget, "defaults", {});
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
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
|
+
var _jestAxe = require("jest-axe");
|
|
5
|
+
require("../../tree.jquery");
|
|
6
|
+
var _exampleData = _interopRequireDefault(require("../support/exampleData"));
|
|
7
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
8
|
+
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 methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), 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; }
|
|
9
|
+
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); } }
|
|
10
|
+
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); }); }; }
|
|
11
|
+
expect.extend(_jestAxe.toHaveNoViolations);
|
|
12
|
+
beforeEach(function () {
|
|
13
|
+
$("body").append('<div id="tree1"></div>');
|
|
14
|
+
});
|
|
15
|
+
afterEach(function () {
|
|
16
|
+
var $tree = $("#tree1");
|
|
17
|
+
$tree.tree("destroy");
|
|
18
|
+
$tree.remove();
|
|
19
|
+
});
|
|
20
|
+
it("has an accessible ui", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
21
|
+
var $tree, element;
|
|
22
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
23
|
+
while (1) switch (_context.prev = _context.next) {
|
|
24
|
+
case 0:
|
|
25
|
+
$tree = $("#tree1");
|
|
26
|
+
$tree.tree({
|
|
27
|
+
data: _exampleData["default"]
|
|
28
|
+
});
|
|
29
|
+
element = $tree.get()[0];
|
|
30
|
+
_context.next = 5;
|
|
31
|
+
return expect((0, _jestAxe.axe)(element)).resolves.toHaveNoViolations();
|
|
32
|
+
case 5:
|
|
33
|
+
case "end":
|
|
34
|
+
return _context.stop();
|
|
35
|
+
}
|
|
36
|
+
}, _callee);
|
|
37
|
+
})));
|
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _givens = _interopRequireDefault(require("givens"));
|
|
4
|
-
|
|
5
4
|
require("../../tree.jquery");
|
|
6
|
-
|
|
7
5
|
var _exampleData = _interopRequireDefault(require("../support/exampleData"));
|
|
8
|
-
|
|
9
6
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
10
|
-
|
|
11
7
|
beforeEach(function () {
|
|
12
8
|
$("body").append('<div id="tree1"></div>');
|
|
13
9
|
});
|
|
@@ -1,19 +1,17 @@
|
|
|
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); }
|
|
3
4
|
var _givens = _interopRequireDefault(require("givens"));
|
|
4
|
-
|
|
5
5
|
var _msw = require("msw");
|
|
6
|
-
|
|
7
6
|
var _node = require("msw/node");
|
|
8
|
-
|
|
7
|
+
var _dom = require("@testing-library/dom");
|
|
9
8
|
require("../../tree.jquery");
|
|
10
|
-
|
|
11
9
|
var _exampleData = _interopRequireDefault(require("../support/exampleData"));
|
|
12
|
-
|
|
13
10
|
var _testUtil = require("../support/testUtil");
|
|
14
|
-
|
|
15
11
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
16
|
-
|
|
12
|
+
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 methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), 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; }
|
|
13
|
+
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); } }
|
|
14
|
+
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); }); }; }
|
|
17
15
|
var context = describe;
|
|
18
16
|
var server = (0, _node.setupServer)();
|
|
19
17
|
beforeAll(function () {
|
|
@@ -48,14 +46,12 @@ describe("tree.click", function () {
|
|
|
48
46
|
});
|
|
49
47
|
});
|
|
50
48
|
it("fires tree.click", function () {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
given.titleSpan.trigger("click");
|
|
58
|
-
});
|
|
49
|
+
var onClick = jest.fn();
|
|
50
|
+
given.$tree.on("tree.click", onClick);
|
|
51
|
+
given.titleSpan.trigger("click");
|
|
52
|
+
expect(onClick).toHaveBeenCalledWith(expect.objectContaining({
|
|
53
|
+
node: given.node1
|
|
54
|
+
}));
|
|
59
55
|
});
|
|
60
56
|
});
|
|
61
57
|
describe("tree.contextmenu", function () {
|
|
@@ -75,14 +71,12 @@ describe("tree.contextmenu", function () {
|
|
|
75
71
|
});
|
|
76
72
|
});
|
|
77
73
|
it("fires tree.contextmenu", function () {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
given.titleSpan.contextmenu();
|
|
85
|
-
});
|
|
74
|
+
var onContextMenu = jest.fn();
|
|
75
|
+
given.$tree.on("tree.contextmenu", onContextMenu);
|
|
76
|
+
given.titleSpan.trigger("contextmenu");
|
|
77
|
+
expect(onContextMenu).toHaveBeenCalledWith(expect.objectContaining({
|
|
78
|
+
node: given.node1
|
|
79
|
+
}));
|
|
86
80
|
});
|
|
87
81
|
});
|
|
88
82
|
describe("tree.dblclick", function () {
|
|
@@ -102,14 +96,12 @@ describe("tree.dblclick", function () {
|
|
|
102
96
|
});
|
|
103
97
|
});
|
|
104
98
|
it("fires tree.dblclick", function () {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
given.titleSpan.trigger("dblclick");
|
|
112
|
-
});
|
|
99
|
+
var onDoubleClick = jest.fn();
|
|
100
|
+
given.$tree.on("tree.dblclick", onDoubleClick);
|
|
101
|
+
given.titleSpan.trigger("dblclick");
|
|
102
|
+
expect(onDoubleClick).toHaveBeenCalledWith(expect.objectContaining({
|
|
103
|
+
node: given.node1
|
|
104
|
+
}));
|
|
113
105
|
});
|
|
114
106
|
});
|
|
115
107
|
describe("tree.init", function () {
|
|
@@ -119,18 +111,14 @@ describe("tree.init", function () {
|
|
|
119
111
|
});
|
|
120
112
|
context("with json data", function () {
|
|
121
113
|
it("is called", function () {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
name: "node2"
|
|
127
|
-
});
|
|
128
|
-
done();
|
|
129
|
-
});
|
|
130
|
-
given.$tree.tree({
|
|
131
|
-
data: _exampleData["default"]
|
|
132
|
-
});
|
|
114
|
+
var onInit = jest.fn();
|
|
115
|
+
given.$tree.on("tree.init", onInit);
|
|
116
|
+
given.$tree.tree({
|
|
117
|
+
data: _exampleData["default"]
|
|
133
118
|
});
|
|
119
|
+
|
|
120
|
+
// eslint-disable-next-line jest/prefer-called-with
|
|
121
|
+
expect(onInit).toHaveBeenCalled();
|
|
134
122
|
});
|
|
135
123
|
});
|
|
136
124
|
context("with data loaded from an url", function () {
|
|
@@ -139,20 +127,27 @@ describe("tree.init", function () {
|
|
|
139
127
|
return response(ctx.status(200), ctx.json(_exampleData["default"]));
|
|
140
128
|
}));
|
|
141
129
|
});
|
|
142
|
-
it("is called", function () {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
130
|
+
it("is called", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
131
|
+
var onInit;
|
|
132
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
133
|
+
while (1) switch (_context.prev = _context.next) {
|
|
134
|
+
case 0:
|
|
135
|
+
onInit = jest.fn();
|
|
136
|
+
given.$tree.on("tree.init", onInit);
|
|
137
|
+
given.$tree.tree({
|
|
138
|
+
dataUrl: "/tree/"
|
|
139
|
+
});
|
|
140
|
+
_context.next = 5;
|
|
141
|
+
return (0, _dom.waitFor)(function () {
|
|
142
|
+
// eslint-disable-next-line jest/prefer-called-with
|
|
143
|
+
expect(onInit).toHaveBeenCalled();
|
|
144
|
+
});
|
|
145
|
+
case 5:
|
|
146
|
+
case "end":
|
|
147
|
+
return _context.stop();
|
|
148
|
+
}
|
|
149
|
+
}, _callee);
|
|
150
|
+
})));
|
|
156
151
|
});
|
|
157
152
|
});
|
|
158
153
|
describe("tree.load_data", function () {
|
|
@@ -162,16 +157,14 @@ describe("tree.load_data", function () {
|
|
|
162
157
|
});
|
|
163
158
|
context("when the tree is initialized with data", function () {
|
|
164
159
|
it("fires tree.load_data", function () {
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
resolve();
|
|
170
|
-
});
|
|
171
|
-
given.$tree.tree({
|
|
172
|
-
data: _exampleData["default"]
|
|
173
|
-
});
|
|
160
|
+
var onLoadData = jest.fn();
|
|
161
|
+
given.$tree.on("tree.load_data", onLoadData);
|
|
162
|
+
given.$tree.tree({
|
|
163
|
+
data: _exampleData["default"]
|
|
174
164
|
});
|
|
165
|
+
expect(onLoadData).toHaveBeenCalledWith(expect.objectContaining({
|
|
166
|
+
tree_data: _exampleData["default"]
|
|
167
|
+
}));
|
|
175
168
|
});
|
|
176
169
|
});
|
|
177
170
|
});
|
|
@@ -191,31 +184,27 @@ describe("tree.select", function () {
|
|
|
191
184
|
data: _exampleData["default"]
|
|
192
185
|
});
|
|
193
186
|
});
|
|
194
|
-
it("fires tree.
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
given.titleSpan.trigger("click");
|
|
203
|
-
});
|
|
187
|
+
it("fires tree.select", function () {
|
|
188
|
+
var onSelect = jest.fn();
|
|
189
|
+
given.$tree.on("tree.select", onSelect);
|
|
190
|
+
given.titleSpan.trigger("click");
|
|
191
|
+
expect(onSelect).toHaveBeenCalledWith(expect.objectContaining({
|
|
192
|
+
node: given.node1,
|
|
193
|
+
deselected_node: null
|
|
194
|
+
}));
|
|
204
195
|
});
|
|
205
196
|
context("when the node was selected", function () {
|
|
206
197
|
beforeEach(function () {
|
|
207
198
|
given.$tree.tree("selectNode", given.node1);
|
|
208
199
|
});
|
|
209
200
|
it("fires tree.select with node is null", function () {
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
given.titleSpan.trigger("click");
|
|
218
|
-
});
|
|
201
|
+
var onSelect = jest.fn();
|
|
202
|
+
given.$tree.on("tree.select", onSelect);
|
|
203
|
+
given.titleSpan.trigger("click");
|
|
204
|
+
expect(onSelect).toHaveBeenCalledWith(expect.objectContaining({
|
|
205
|
+
node: null,
|
|
206
|
+
previous_node: given.node1
|
|
207
|
+
}));
|
|
219
208
|
});
|
|
220
209
|
});
|
|
221
210
|
});
|
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _givens = _interopRequireDefault(require("givens"));
|
|
4
|
-
|
|
5
4
|
require("../../tree.jquery");
|
|
6
|
-
|
|
7
5
|
var _exampleData = _interopRequireDefault(require("../support/exampleData"));
|
|
8
|
-
|
|
9
6
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
10
|
-
|
|
11
7
|
var context = describe;
|
|
12
8
|
beforeEach(function () {
|
|
13
9
|
$("body").append('<div id="tree1"></div>');
|
|
@@ -39,11 +35,9 @@ describe("keyboard support", function () {
|
|
|
39
35
|
autoOpen: given.autoOpen,
|
|
40
36
|
data: _exampleData["default"]
|
|
41
37
|
});
|
|
42
|
-
|
|
43
38
|
if (given.initialSelectedNode) {
|
|
44
39
|
given.$tree.tree("selectNode", given.initialSelectedNode);
|
|
45
40
|
}
|
|
46
|
-
|
|
47
41
|
given.$tree.trigger($.Event("keydown", {
|
|
48
42
|
which: given.pressedKey
|
|
49
43
|
}));
|