jqtree 1.6.2 → 1.7.0
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/.eslintrc +3 -12
- package/.github/workflows/ci.yml +57 -30
- package/.github/workflows/codeql-analysis.yml +9 -5
- package/.prettier +3 -0
- package/.tool-versions +1 -0
- package/README.md +12 -9
- package/bower.json +10 -3
- package/{.postcssrc → config/.postcssrc} +0 -0
- package/{babel.config.json → config/babel.config.json} +0 -0
- package/{babel.coverage.config.json → config/babel.coverage.config.json} +0 -0
- package/{jest-jsdom.config.js → config/jest.config.js} +8 -3
- package/config/playwright.config.js +18 -0
- package/config/production +4 -0
- package/{rollup.config.js → config/rollup.config.mjs} +3 -8
- package/{jqtree.postcss → css/jqtree.postcss} +0 -0
- package/devserver/index.html +1 -9
- package/docs/Gemfile +2 -0
- package/docs/Gemfile.lock +263 -0
- package/{_config.yml → docs/_config.yml} +8 -1
- package/{_entries → docs/_entries}/01_general.md +0 -0
- package/{_entries → docs/_entries}/02_introduction.md +0 -0
- package/{_entries → docs/_entries}/03_features.md +1 -1
- package/{_entries → docs/_entries}/04_demo.html +1 -7
- package/{_entries → docs/_entries}/05_requirements.md +0 -0
- package/{_entries → docs/_entries}/06_downloads.md +0 -0
- package/{_entries → docs/_entries}/07_tutorial.md +0 -0
- package/{_entries → docs/_entries}/08_examples.md +0 -0
- package/{_entries → docs/_entries}/09_usecases.md +0 -0
- package/{_entries → docs/_entries}/10_changelog.md +13 -0
- package/{_entries → docs/_entries}/11_options.md +0 -0
- package/{_entries → docs/_entries}/12_animationspeed.md +0 -0
- package/{_entries → docs/_entries}/13_autoescape.md +0 -0
- package/{_entries → docs/_entries}/14_autoopen.md +0 -0
- package/{_entries → docs/_entries}/15_buttonleft.md +0 -0
- package/{_entries → docs/_entries}/16_closedicon.md +0 -0
- package/{_entries → docs/_entries}/17_data.md +0 -0
- package/{_entries → docs/_entries}/18_datafilter.md +0 -0
- package/{_entries → docs/_entries}/19_data-url.md +0 -0
- package/{_entries → docs/_entries}/20_draganddrop.md +0 -0
- package/{_entries → docs/_entries}/21_keyboardsupport.md +0 -0
- package/{_entries → docs/_entries}/22_oncanmove.md +0 -0
- package/{_entries → docs/_entries}/23_oncanmoveto.md +2 -2
- package/{_entries → docs/_entries}/24_oncanselectnode.md +0 -0
- package/{_entries → docs/_entries}/25_oncreateli.md +2 -2
- package/{_entries → docs/_entries}/26_ondragmove.md +0 -0
- package/{_entries → docs/_entries}/27_ondragstop.md +0 -0
- package/{_entries → docs/_entries}/28_onismovehandle.md +0 -0
- package/{_entries → docs/_entries}/29_onloadfailed.md +0 -0
- package/{_entries → docs/_entries}/30_onloading.md +2 -2
- package/{_entries → docs/_entries}/31_openedicon.md +0 -0
- package/{_entries → docs/_entries}/32_openfolderdelay.md +2 -0
- package/{_entries → docs/_entries}/33_rtl.md +0 -0
- package/{_entries → docs/_entries}/34_savestate.md +0 -0
- package/{_entries → docs/_entries}/35_selectable.md +0 -0
- package/{_entries → docs/_entries}/36_showemptyfolder.md +0 -0
- package/{_entries → docs/_entries}/37_slide.md +0 -0
- package/{_entries → docs/_entries}/38_start_dnd_delay.md +0 -0
- package/{_entries → docs/_entries}/39_tabindex.md +0 -0
- package/{_entries → docs/_entries}/40_usecontextmenu.md +0 -0
- package/{_entries → docs/_entries}/41_functions.md +0 -0
- package/{_entries → docs/_entries}/42_addparentnode.md +1 -1
- package/{_entries → docs/_entries}/43_addnodeafter.md +1 -1
- package/{_entries → docs/_entries}/44_addnodebefore.md +1 -1
- package/{_entries → docs/_entries}/45_appendnode.md +5 -5
- package/{_entries → docs/_entries}/46_closenode.md +0 -0
- package/{_entries → docs/_entries}/47_destroy.md +0 -0
- package/{_entries → docs/_entries}/48_getnodebycallback.md +0 -0
- package/{_entries → docs/_entries}/49_getnodebyid.md +0 -0
- package/{_entries → docs/_entries}/50_getnodebyhtmlelement.md +2 -2
- package/{_entries → docs/_entries}/51_getselectednode.md +0 -0
- package/{_entries → docs/_entries}/52_getstate.md +0 -0
- package/{_entries → docs/_entries}/53_gettree.md +1 -1
- package/{_entries → docs/_entries}/54_isdragging.md +1 -1
- package/{_entries → docs/_entries}/55_loaddata.md +3 -3
- package/{_entries → docs/_entries}/56_loaddatafromurl.md +4 -4
- package/{_entries → docs/_entries}/57_movedown.md +0 -0
- package/{_entries → docs/_entries}/58_movenode.md +3 -3
- package/{_entries → docs/_entries}/59_moveup.md +0 -0
- package/{_entries → docs/_entries}/60_opennode.md +3 -3
- package/docs/_entries/61_prependnode.md +21 -0
- package/{_entries → docs/_entries}/62_refresh.md +0 -0
- package/{_entries → docs/_entries}/63_reload.md +2 -2
- package/{_entries → docs/_entries}/64_removenode.md +0 -0
- package/{_entries → docs/_entries}/65_selectnode.md +0 -0
- package/{_entries → docs/_entries}/66_scrolltonode.md +0 -0
- package/{_entries → docs/_entries}/67_setoption.md +0 -0
- package/{_entries → docs/_entries}/68_setstate.md +0 -0
- package/{_entries → docs/_entries}/69_toggle.md +0 -0
- package/{_entries → docs/_entries}/70_tojson.md +0 -0
- package/{_entries → docs/_entries}/71_updatenode.md +1 -1
- package/{_entries → docs/_entries}/72_events.md +0 -0
- package/{_entries → docs/_entries}/73_tree-click.md +0 -0
- package/{_entries → docs/_entries}/74_tree-close.md +0 -0
- package/{_entries → docs/_entries}/75_tree-contextmenu.md +0 -0
- package/{_entries → docs/_entries}/76_tree-dblclick.md +0 -0
- package/{_entries → docs/_entries}/77_tree-init.md +0 -0
- package/{_entries → docs/_entries}/78_tree-load-data.md +0 -0
- package/{_entries → docs/_entries}/79_tree-loading-data.md +0 -0
- package/{_entries → docs/_entries}/80_tree-move.md +0 -0
- package/{_entries → docs/_entries}/81_tree-refresh.md +0 -0
- package/{_entries → docs/_entries}/82_tree-open.md +0 -0
- package/{_entries → docs/_entries}/83_tree-select.md +0 -0
- package/{_entries → docs/_entries}/84_multiple-selection.md +0 -0
- package/{_entries → docs/_entries}/85_add-to-selection.md +0 -0
- package/{_entries → docs/_entries}/86_get-selected-nodes.md +0 -0
- package/{_entries → docs/_entries}/87_is-node-selected.md +1 -1
- package/{_entries → docs/_entries}/88_remove-from-selection.md +0 -0
- package/{_entries → docs/_entries}/89_node-functions.md +0 -0
- package/{_entries → docs/_entries}/90_children.md +0 -0
- package/{_entries → docs/_entries}/91_getdata.md +2 -2
- package/{_entries → docs/_entries}/92_getlevel.md +0 -0
- package/docs/_entries/93_getnextnode.md +15 -0
- package/{_entries → docs/_entries}/94_getnextsibling.md +0 -0
- package/{_entries/95_getpreviousnode.md → docs/_entries/95_getnextvisiblenode.md} +1 -1
- package/docs/_entries/96_getpreviousnode.md +0 -0
- package/{_entries/96_getprevioussibling.md → docs/_entries/97_getprevioussibling.md} +0 -0
- package/docs/_entries/98_getpreviousvisiblenode.md +14 -0
- package/{_entries/97_parent.md → docs/_entries/99_parent.md} +1 -1
- package/{_entries → docs/_entries}/insert.py +0 -0
- package/{_entries → docs/_entries}/renumber.py +0 -0
- package/{_examples → docs/_examples}/01_load_json_data.html +3 -5
- package/{_examples → docs/_examples}/02_load_json_data_from_server.html +3 -5
- package/{_examples → docs/_examples}/03_drag_and_drop.html +3 -5
- package/{_examples → docs/_examples}/04_save_state.html +3 -5
- package/{_examples → docs/_examples}/05_load_on_demand.html +3 -5
- package/{_examples → docs/_examples}/06_autoescape.html +3 -5
- package/{_examples → docs/_examples}/07_autoscroll.html +3 -5
- package/{_examples → docs/_examples}/08_multiple_select.html +3 -5
- package/{_examples → docs/_examples}/09_custom_html.html +3 -5
- package/{_examples → docs/_examples}/10_icon_buttons.html +3 -5
- package/{_examples → docs/_examples}/11_right-to-left.html +3 -5
- package/{_examples → docs/_examples}/12_button_on_right.html +3 -5
- package/docs/_examples/13_drag_outside.html +48 -0
- package/{_examples → docs/_examples}/14_filter.html +7 -9
- package/docs/_layouts/example.html +7 -0
- package/{_layouts/base.html → docs/_layouts/page.html} +4 -11
- package/docs/documentation.css +3 -0
- package/docs/index.html +65 -0
- package/docs/jqtree.css +189 -0
- package/docs/package.json +22 -0
- package/docs/pnpm-lock.yaml +798 -0
- package/docs/postcss.config.js +7 -0
- package/{static → docs/static}/bower.json +1 -2
- package/{static → docs/static}/bower_components/fontawesome/css/all.min.css +0 -0
- package/{static → docs/static}/bower_components/fontawesome/webfonts/fa-brands-400.eot +0 -0
- package/{static → docs/static}/bower_components/fontawesome/webfonts/fa-brands-400.svg +0 -0
- package/{static → docs/static}/bower_components/fontawesome/webfonts/fa-brands-400.ttf +0 -0
- package/{static → docs/static}/bower_components/fontawesome/webfonts/fa-brands-400.woff +0 -0
- package/{static → docs/static}/bower_components/fontawesome/webfonts/fa-brands-400.woff2 +0 -0
- package/{static → docs/static}/bower_components/fontawesome/webfonts/fa-regular-400.eot +0 -0
- package/{static → docs/static}/bower_components/fontawesome/webfonts/fa-regular-400.svg +0 -0
- package/{static → docs/static}/bower_components/fontawesome/webfonts/fa-regular-400.ttf +0 -0
- package/{static → docs/static}/bower_components/fontawesome/webfonts/fa-regular-400.woff +0 -0
- package/{static → docs/static}/bower_components/fontawesome/webfonts/fa-regular-400.woff2 +0 -0
- package/{static → docs/static}/bower_components/fontawesome/webfonts/fa-solid-900.eot +0 -0
- package/{static → docs/static}/bower_components/fontawesome/webfonts/fa-solid-900.svg +0 -0
- package/{static → docs/static}/bower_components/fontawesome/webfonts/fa-solid-900.ttf +0 -0
- package/{static → docs/static}/bower_components/fontawesome/webfonts/fa-solid-900.woff +0 -0
- package/{static → docs/static}/bower_components/fontawesome/webfonts/fa-solid-900.woff2 +0 -0
- package/{static → docs/static}/bower_components/jquery/dist/jquery.js +209 -97
- package/docs/static/bower_components/jquery/dist/jquery.min.js +2 -0
- package/{static → docs/static}/bower_components/jquery-mockjax/dist/jquery.mockjax.js +0 -0
- package/docs/static/documentation.css +1453 -0
- package/docs/static/documentation.js +26 -0
- package/{static → docs/static}/example.css +5 -38
- package/{static → docs/static}/example.postcss +5 -35
- package/{static → docs/static}/example_data.js +0 -0
- package/{static → docs/static}/examples/autoescape.js +0 -0
- package/{static → docs/static}/examples/autoscroll.js +0 -0
- package/{static → docs/static}/examples/button-on-right.js +0 -0
- package/{static → docs/static}/examples/custom_html.js +5 -9
- package/{static → docs/static}/examples/drag-outside.js +0 -0
- package/{static → docs/static}/examples/drag_and_drop.js +0 -0
- package/{static → docs/static}/examples/filter.js +2 -2
- package/{static → docs/static}/examples/icon_buttons.js +0 -0
- package/{static → docs/static}/examples/load_json_data.js +0 -0
- package/{static → docs/static}/examples/load_json_data_from_server.js +0 -0
- package/{static → docs/static}/examples/load_on_demand.js +0 -0
- package/{static → docs/static}/examples/multiple_select.js +0 -0
- package/{static → docs/static}/examples/right-to-left.js +0 -0
- package/{static → docs/static}/examples/save_state.js +0 -0
- package/{static → docs/static}/monokai.css +0 -0
- package/{static → docs/static}/spinner.gif +0 -0
- package/docs/tailwind.config.js +16 -0
- package/docs/tree.jquery.js +21 -0
- package/lib/dataLoader.js +5 -31
- package/lib/dragAndDropHandler.js +26 -135
- package/lib/elementsRenderer.js +29 -59
- package/lib/keyHandler.js +8 -32
- package/lib/mouse.widget.js +16 -77
- package/lib/node.js +60 -125
- package/lib/nodeElement.js +8 -75
- package/lib/playwright/coverage.js +101 -0
- package/lib/playwright/playwright.test.js +212 -182
- package/lib/playwright/testUtils.js +201 -0
- package/lib/saveStateHandler.js +12 -61
- package/lib/scrollHandler.js +17 -74
- package/lib/selectNodeHandler.js +5 -24
- package/lib/simple.widget.js +18 -53
- package/lib/test/jqTree/create.test.js +0 -4
- package/lib/test/jqTree/events.test.js +10 -16
- package/lib/test/jqTree/keyboard.test.js +0 -6
- package/lib/test/jqTree/loadOnDemand.test.js +107 -139
- package/lib/test/jqTree/methods.test.js +136 -159
- package/lib/test/jqTree/options.test.js +53 -63
- package/lib/test/node.test.js +127 -72
- 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 +32 -243
- package/lib/util.js +0 -6
- package/lib/version.js +1 -1
- package/package.json +54 -54
- package/src/dragAndDropHandler.ts +8 -4
- package/src/jqtreeOptions.ts +1 -1
- package/src/keyHandler.ts +3 -3
- package/src/node.ts +43 -12
- package/src/playwright/.eslintrc +2 -2
- package/src/playwright/coverage.ts +41 -0
- package/src/playwright/playwright.test.ts +50 -52
- package/src/playwright/playwright.test.ts-snapshots/with-dragAndDrop-moves-a-node-1-Chromium-darwin.png +0 -0
- package/src/playwright/playwright.test.ts-snapshots/with-dragAndDrop-moves-a-node-1-Chromium-linux.png +0 -0
- package/src/playwright/playwright.test.ts-snapshots/without-dragAndDrop-displays-a-tree-1-Chromium-darwin.png +0 -0
- package/src/playwright/playwright.test.ts-snapshots/without-dragAndDrop-displays-a-tree-1-Chromium-linux.png +0 -0
- package/src/playwright/playwright.test.ts-snapshots/without-dragAndDrop-selects-a-node-1-Chromium-darwin.png +0 -0
- package/src/playwright/playwright.test.ts-snapshots/without-dragAndDrop-selects-a-node-1-Chromium-linux.png +0 -0
- package/src/playwright/testUtils.ts +122 -0
- package/src/test/.eslintrc +15 -3
- package/src/test/jqTree/events.test.ts +10 -9
- package/src/test/jqTree/loadOnDemand.test.ts +10 -10
- package/src/test/jqTree/methods.test.ts +37 -45
- package/src/test/jqTree/options.test.ts +26 -28
- package/src/test/node.test.ts +146 -54
- package/src/tree.jquery.d.ts +1 -1
- package/src/tree.jquery.ts +6 -5
- package/src/version.ts +1 -1
- package/tree.jquery.debug.js +217 -867
- package/tree.jquery.debug.js.map +1 -1
- package/tree.jquery.js +3 -3
- package/tree.jquery.js.map +1 -1
- package/_entries/61_prependnode.md +0 -21
- package/_entries/93_getnextnode.md +0 -12
- package/_examples/13_drag_outside.html +0 -26
- package/_layouts/frontpage.html +0 -20
- package/_layouts/page.html +0 -7
- package/index.html +0 -48
- package/jest-browser.config.js +0 -15
- package/jest-playwright.config.js +0 -21
- package/jest.config.js +0 -8
- package/lib/playwright/testUtil.js +0 -459
- package/lib/playwright/visualRegression.js +0 -193
- package/production +0 -5
- package/src/playwright/screenshots/displays_a_tree_Desktop.png +0 -0
- package/src/playwright/screenshots/displays_a_tree_iPhone 6.png +0 -0
- package/src/playwright/screenshots/moves_a_node_Desktop.png +0 -0
- package/src/playwright/screenshots/moves_a_node_iPhone 6.png +0 -0
- package/src/playwright/screenshots/opens_a_node_Desktop.png +0 -0
- package/src/playwright/screenshots/opens_a_node_iPhone 6.png +0 -0
- package/src/playwright/screenshots/selects_a_node_Desktop.png +0 -0
- package/src/playwright/screenshots/selects_a_node_iPhone 6.png +0 -0
- package/src/playwright/testUtil.ts +0 -170
- package/src/playwright/visualRegression.ts +0 -88
- package/static/bower_components/bootstrap/dist/css/bootstrap-theme.min.css +0 -6
- package/static/bower_components/bootstrap/dist/css/bootstrap.min.css +0 -6
- package/static/bower_components/bootstrap/dist/fonts/glyphicons-halflings-regular.eot +0 -0
- package/static/bower_components/bootstrap/dist/fonts/glyphicons-halflings-regular.svg +0 -288
- package/static/bower_components/bootstrap/dist/fonts/glyphicons-halflings-regular.ttf +0 -0
- package/static/bower_components/bootstrap/dist/fonts/glyphicons-halflings-regular.woff +0 -0
- package/static/bower_components/bootstrap/dist/fonts/glyphicons-halflings-regular.woff2 +0 -0
- package/static/bower_components/bootstrap/dist/js/bootstrap.min.js +0 -6
- package/static/bower_components/jquery/dist/jquery.min.js +0 -2
- package/static/documentation.css +0 -171
- package/static/documentation.js +0 -48
|
@@ -1,37 +1,36 @@
|
|
|
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 _dom = require("@testing-library/dom");
|
|
6
|
-
|
|
7
6
|
var _msw = require("msw");
|
|
8
|
-
|
|
9
7
|
var _node = require("msw/node");
|
|
10
|
-
|
|
11
8
|
require("../../tree.jquery");
|
|
12
|
-
|
|
13
9
|
var _exampleData = _interopRequireDefault(require("../support/exampleData"));
|
|
14
|
-
|
|
15
10
|
var _testUtil = require("../support/testUtil");
|
|
16
|
-
|
|
17
11
|
var _version = _interopRequireDefault(require("../../version"));
|
|
18
|
-
|
|
19
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
20
|
-
|
|
13
|
+
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; }
|
|
21
14
|
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); } }
|
|
22
|
-
|
|
23
15
|
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); }); }; }
|
|
24
|
-
|
|
25
16
|
var context = describe;
|
|
17
|
+
var server = (0, _node.setupServer)();
|
|
18
|
+
beforeAll(function () {
|
|
19
|
+
return server.listen();
|
|
20
|
+
});
|
|
26
21
|
beforeEach(function () {
|
|
27
22
|
$("body").append('<div id="tree1"></div>');
|
|
28
23
|
});
|
|
29
24
|
afterEach(function () {
|
|
25
|
+
server.resetHandlers();
|
|
30
26
|
var $tree = $("#tree1");
|
|
31
27
|
$tree.tree("destroy");
|
|
32
28
|
$tree.remove();
|
|
33
29
|
localStorage.clear();
|
|
34
30
|
});
|
|
31
|
+
afterAll(function () {
|
|
32
|
+
return server.close();
|
|
33
|
+
});
|
|
35
34
|
describe("addNodeAfter", function () {
|
|
36
35
|
var given = (0, _givens["default"])();
|
|
37
36
|
given("$tree", function () {
|
|
@@ -259,7 +258,6 @@ describe("getNodeByCallback", function () {
|
|
|
259
258
|
var callback = function callback(node) {
|
|
260
259
|
return node.name.startsWith("chi");
|
|
261
260
|
};
|
|
262
|
-
|
|
263
261
|
expect(given.$tree.tree("getNodeByCallback", callback)).toMatchObject({
|
|
264
262
|
name: "child1"
|
|
265
263
|
});
|
|
@@ -640,44 +638,31 @@ describe("loadDataFromUrl", function () {
|
|
|
640
638
|
given("$tree", function () {
|
|
641
639
|
return $("#tree1");
|
|
642
640
|
});
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
server = (0, _node.setupServer)(_msw.rest.get("/tree/", function (_request, response, ctx) {
|
|
641
|
+
beforeEach(function () {
|
|
642
|
+
server.use(_msw.rest.get("/tree/", function (_request, response, ctx) {
|
|
646
643
|
return response(ctx.status(200), ctx.json(given.serverData));
|
|
647
644
|
}));
|
|
648
|
-
server.listen();
|
|
649
|
-
});
|
|
650
|
-
afterAll(function () {
|
|
651
|
-
var _server;
|
|
652
|
-
|
|
653
|
-
(_server = server) === null || _server === void 0 ? void 0 : _server.close();
|
|
654
|
-
});
|
|
655
|
-
beforeEach(function () {
|
|
656
645
|
given.$tree.tree({
|
|
657
646
|
data: given.initialData
|
|
658
647
|
});
|
|
659
648
|
});
|
|
660
649
|
context("with url parameter", function () {
|
|
661
|
-
it("loads the tree", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/
|
|
662
|
-
return
|
|
663
|
-
while (1) {
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
case 4:
|
|
678
|
-
case "end":
|
|
679
|
-
return _context.stop();
|
|
680
|
-
}
|
|
650
|
+
it("loads the tree", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
651
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
652
|
+
while (1) switch (_context.prev = _context.next) {
|
|
653
|
+
case 0:
|
|
654
|
+
given.$tree.tree("loadDataFromUrl", "/tree/");
|
|
655
|
+
_context.next = 3;
|
|
656
|
+
return _dom.screen.findByText("node1");
|
|
657
|
+
case 3:
|
|
658
|
+
expect(given.$tree).toHaveTreeStructure([expect.objectContaining({
|
|
659
|
+
name: "node1"
|
|
660
|
+
}), expect.objectContaining({
|
|
661
|
+
name: "node2"
|
|
662
|
+
})]);
|
|
663
|
+
case 4:
|
|
664
|
+
case "end":
|
|
665
|
+
return _context.stop();
|
|
681
666
|
}
|
|
682
667
|
}, _callee);
|
|
683
668
|
})));
|
|
@@ -688,60 +673,52 @@ describe("loadDataFromUrl", function () {
|
|
|
688
673
|
given("serverData", function () {
|
|
689
674
|
return ["new1", "new2"];
|
|
690
675
|
});
|
|
691
|
-
it("loads a subtree", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/
|
|
676
|
+
it("loads a subtree", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
692
677
|
var parentNode;
|
|
693
|
-
return
|
|
694
|
-
while (1) {
|
|
695
|
-
switch (_context2.prev = _context2.next) {
|
|
696
|
-
case 0:
|
|
697
|
-
parentNode = given.$tree.tree("getNodeByNameMustExist", "initial1");
|
|
698
|
-
given.$tree.tree("loadDataFromUrl", "/tree/", parentNode);
|
|
699
|
-
_context2.next = 4;
|
|
700
|
-
return _dom.screen.findByText("new1");
|
|
701
|
-
|
|
702
|
-
case 4:
|
|
703
|
-
expect(given.$tree).toHaveTreeStructure([expect.objectContaining({
|
|
704
|
-
name: "initial1",
|
|
705
|
-
children: [expect.objectContaining({
|
|
706
|
-
name: "new1"
|
|
707
|
-
}), expect.objectContaining({
|
|
708
|
-
name: "new2"
|
|
709
|
-
})]
|
|
710
|
-
}), expect.objectContaining({
|
|
711
|
-
name: "initial2"
|
|
712
|
-
})]);
|
|
713
|
-
|
|
714
|
-
case 5:
|
|
715
|
-
case "end":
|
|
716
|
-
return _context2.stop();
|
|
717
|
-
}
|
|
718
|
-
}
|
|
719
|
-
}, _callee2);
|
|
720
|
-
})));
|
|
721
|
-
});
|
|
722
|
-
});
|
|
723
|
-
context("without url parameter", function () {
|
|
724
|
-
it("loads the data from dataUrl", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3() {
|
|
725
|
-
return regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
726
|
-
while (1) {
|
|
727
|
-
switch (_context3.prev = _context3.next) {
|
|
678
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
679
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
728
680
|
case 0:
|
|
729
|
-
given.$tree.tree("
|
|
730
|
-
given.$tree.tree("loadDataFromUrl");
|
|
731
|
-
|
|
732
|
-
return _dom.screen.findByText("
|
|
733
|
-
|
|
681
|
+
parentNode = given.$tree.tree("getNodeByNameMustExist", "initial1");
|
|
682
|
+
given.$tree.tree("loadDataFromUrl", "/tree/", parentNode);
|
|
683
|
+
_context2.next = 4;
|
|
684
|
+
return _dom.screen.findByText("new1");
|
|
734
685
|
case 4:
|
|
735
686
|
expect(given.$tree).toHaveTreeStructure([expect.objectContaining({
|
|
736
|
-
name: "
|
|
687
|
+
name: "initial1",
|
|
688
|
+
children: [expect.objectContaining({
|
|
689
|
+
name: "new1"
|
|
690
|
+
}), expect.objectContaining({
|
|
691
|
+
name: "new2"
|
|
692
|
+
})]
|
|
737
693
|
}), expect.objectContaining({
|
|
738
|
-
name: "
|
|
694
|
+
name: "initial2"
|
|
739
695
|
})]);
|
|
740
|
-
|
|
741
696
|
case 5:
|
|
742
697
|
case "end":
|
|
743
|
-
return
|
|
698
|
+
return _context2.stop();
|
|
744
699
|
}
|
|
700
|
+
}, _callee2);
|
|
701
|
+
})));
|
|
702
|
+
});
|
|
703
|
+
});
|
|
704
|
+
context("without url parameter", function () {
|
|
705
|
+
it("loads the data from dataUrl", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
706
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
707
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
708
|
+
case 0:
|
|
709
|
+
given.$tree.tree("setOption", "dataUrl", "/tree/");
|
|
710
|
+
given.$tree.tree("loadDataFromUrl");
|
|
711
|
+
_context3.next = 4;
|
|
712
|
+
return _dom.screen.findByText("node1");
|
|
713
|
+
case 4:
|
|
714
|
+
expect(given.$tree).toHaveTreeStructure([expect.objectContaining({
|
|
715
|
+
name: "node1"
|
|
716
|
+
}), expect.objectContaining({
|
|
717
|
+
name: "node2"
|
|
718
|
+
})]);
|
|
719
|
+
case 5:
|
|
720
|
+
case "end":
|
|
721
|
+
return _context3.stop();
|
|
745
722
|
}
|
|
746
723
|
}, _callee3);
|
|
747
724
|
})));
|
|
@@ -839,13 +816,23 @@ describe("openNode", function () {
|
|
|
839
816
|
expect(given.node1.element).toBeOpen();
|
|
840
817
|
});
|
|
841
818
|
context("with onFinished parameter", function () {
|
|
842
|
-
it("calls the function", function () {
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
819
|
+
it("calls the function", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
820
|
+
var onFinished;
|
|
821
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
822
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
823
|
+
case 0:
|
|
824
|
+
onFinished = jest.fn();
|
|
825
|
+
given.$tree.tree("openNode", given.node1, onFinished);
|
|
826
|
+
_context4.next = 4;
|
|
827
|
+
return (0, _dom.waitFor)(function () {
|
|
828
|
+
expect(onFinished).toHaveBeenCalledWith(given.node1);
|
|
829
|
+
});
|
|
830
|
+
case 4:
|
|
831
|
+
case "end":
|
|
832
|
+
return _context4.stop();
|
|
833
|
+
}
|
|
834
|
+
}, _callee4);
|
|
835
|
+
})));
|
|
849
836
|
});
|
|
850
837
|
});
|
|
851
838
|
describe("prependNode", function () {
|
|
@@ -927,80 +914,72 @@ describe("reload", function () {
|
|
|
927
914
|
given("$tree", function () {
|
|
928
915
|
return $("#tree1");
|
|
929
916
|
});
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
917
|
+
beforeEach( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
|
|
918
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
919
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
920
|
+
case 0:
|
|
921
|
+
server.use(_msw.rest.get("/tree2/", function (_request, response, ctx) {
|
|
922
|
+
return response(ctx.status(200), ctx.json(_exampleData["default"]));
|
|
923
|
+
}));
|
|
924
|
+
given.$tree.tree({
|
|
925
|
+
dataUrl: "/tree2/"
|
|
926
|
+
});
|
|
927
|
+
_context5.next = 4;
|
|
928
|
+
return _dom.screen.findByText("node1");
|
|
929
|
+
case 4:
|
|
930
|
+
given.$tree.tree("removeNode", given.node1);
|
|
931
|
+
case 5:
|
|
932
|
+
case "end":
|
|
933
|
+
return _context5.stop();
|
|
934
|
+
}
|
|
935
|
+
}, _callee5);
|
|
936
|
+
})));
|
|
937
|
+
it("reloads the data from the server", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
|
|
938
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
939
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
940
|
+
case 0:
|
|
941
|
+
expect(given.$tree).toHaveTreeStructure([expect.objectContaining({
|
|
942
|
+
name: "node2"
|
|
943
|
+
})]);
|
|
944
|
+
given.$tree.tree("reload");
|
|
945
|
+
_context6.next = 4;
|
|
946
|
+
return _dom.screen.findByText("node1");
|
|
947
|
+
case 4:
|
|
948
|
+
expect(given.$tree).toHaveTreeStructure([expect.objectContaining({
|
|
949
|
+
name: "node1"
|
|
950
|
+
}), expect.objectContaining({
|
|
951
|
+
name: "node2"
|
|
952
|
+
})]);
|
|
953
|
+
case 5:
|
|
954
|
+
case "end":
|
|
955
|
+
return _context6.stop();
|
|
960
956
|
}
|
|
961
|
-
},
|
|
957
|
+
}, _callee6);
|
|
962
958
|
})));
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
959
|
+
context("with a onFinished parameter", function () {
|
|
960
|
+
it("calls onFinished", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
|
|
961
|
+
var handleFinished;
|
|
962
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
963
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
967
964
|
case 0:
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
965
|
+
handleFinished = jest.fn();
|
|
966
|
+
given.$tree.tree("reload", handleFinished);
|
|
967
|
+
_context7.next = 4;
|
|
968
|
+
return (0, _dom.waitFor)(function () {
|
|
969
|
+
return expect(handleFinished).toHaveBeenCalledWith();
|
|
970
|
+
});
|
|
975
971
|
case 4:
|
|
976
972
|
expect(given.$tree).toHaveTreeStructure([expect.objectContaining({
|
|
977
973
|
name: "node1"
|
|
978
974
|
}), expect.objectContaining({
|
|
979
975
|
name: "node2"
|
|
980
976
|
})]);
|
|
981
|
-
|
|
982
977
|
case 5:
|
|
983
978
|
case "end":
|
|
984
|
-
return
|
|
979
|
+
return _context7.stop();
|
|
985
980
|
}
|
|
986
|
-
}
|
|
987
|
-
}
|
|
988
|
-
})));
|
|
989
|
-
context("with a onFinished parameter", function () {
|
|
990
|
-
it("calls onFinished", function () {
|
|
991
|
-
return new Promise(function (resolve) {
|
|
992
|
-
var handleFinished = function handleFinished() {
|
|
993
|
-
expect(given.$tree).toHaveTreeStructure([expect.objectContaining({
|
|
994
|
-
name: "node1"
|
|
995
|
-
}), expect.objectContaining({
|
|
996
|
-
name: "node2"
|
|
997
|
-
})]);
|
|
998
|
-
resolve();
|
|
999
|
-
};
|
|
1000
|
-
|
|
1001
|
-
given.$tree.tree("reload", handleFinished);
|
|
1002
|
-
});
|
|
1003
|
-
});
|
|
981
|
+
}, _callee7);
|
|
982
|
+
})));
|
|
1004
983
|
});
|
|
1005
984
|
});
|
|
1006
985
|
describe("removeNode", function () {
|
|
@@ -1243,11 +1222,9 @@ describe("updateNode", function () {
|
|
|
1243
1222
|
autoOpen: true,
|
|
1244
1223
|
data: _exampleData["default"]
|
|
1245
1224
|
});
|
|
1246
|
-
|
|
1247
1225
|
if (given.isSelected) {
|
|
1248
1226
|
given.$tree.tree("selectNode", given.node);
|
|
1249
1227
|
}
|
|
1250
|
-
|
|
1251
1228
|
given.$tree.tree("updateNode", given.node, given.nodeData);
|
|
1252
1229
|
});
|
|
1253
1230
|
context("with a string", function () {
|
|
@@ -1,35 +1,35 @@
|
|
|
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 _dom = require("@testing-library/dom");
|
|
6
|
-
|
|
7
6
|
var _msw = require("msw");
|
|
8
|
-
|
|
9
7
|
var _node = require("msw/node");
|
|
10
|
-
|
|
11
8
|
require("../../tree.jquery");
|
|
12
|
-
|
|
13
9
|
var _exampleData = _interopRequireDefault(require("../support/exampleData"));
|
|
14
|
-
|
|
15
10
|
var _testUtil = require("../support/testUtil");
|
|
16
|
-
|
|
17
11
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
18
|
-
|
|
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; }
|
|
19
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); } }
|
|
20
|
-
|
|
21
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); }); }; }
|
|
22
|
-
|
|
23
15
|
var context = describe;
|
|
16
|
+
var server = (0, _node.setupServer)();
|
|
17
|
+
beforeAll(function () {
|
|
18
|
+
return server.listen();
|
|
19
|
+
});
|
|
24
20
|
beforeEach(function () {
|
|
25
21
|
$("body").append('<div id="tree1"></div>');
|
|
26
22
|
});
|
|
27
23
|
afterEach(function () {
|
|
24
|
+
server.resetHandlers();
|
|
28
25
|
var $tree = $("#tree1");
|
|
29
26
|
$tree.tree("destroy");
|
|
30
27
|
$tree.remove();
|
|
31
28
|
localStorage.clear();
|
|
32
29
|
});
|
|
30
|
+
afterAll(function () {
|
|
31
|
+
return server.close();
|
|
32
|
+
});
|
|
33
33
|
describe("autoEscape", function () {
|
|
34
34
|
var given = (0, _givens["default"])();
|
|
35
35
|
given("$tree", function () {
|
|
@@ -193,19 +193,12 @@ describe("dataUrl", function () {
|
|
|
193
193
|
expectedNode: "node1",
|
|
194
194
|
expectedStructure: exampleStructure
|
|
195
195
|
}];
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
server = (0, _node.setupServer)(_msw.rest.get("/tree/", function (request, response, ctx) {
|
|
196
|
+
beforeEach(function () {
|
|
197
|
+
server.use(_msw.rest.get("/tree/", function (request, response, ctx) {
|
|
199
198
|
var nodeName = request.headers.get("node");
|
|
200
199
|
var data = nodeName ? [nodeName] : _exampleData["default"];
|
|
201
200
|
return response(ctx.status(200), ctx.json(data));
|
|
202
201
|
}));
|
|
203
|
-
server.listen();
|
|
204
|
-
});
|
|
205
|
-
afterAll(function () {
|
|
206
|
-
var _server;
|
|
207
|
-
|
|
208
|
-
(_server = server) === null || _server === void 0 ? void 0 : _server.close();
|
|
209
202
|
});
|
|
210
203
|
var given = (0, _givens["default"])();
|
|
211
204
|
given("$tree", function () {
|
|
@@ -213,28 +206,24 @@ describe("dataUrl", function () {
|
|
|
213
206
|
});
|
|
214
207
|
testCases.forEach(function (_ref) {
|
|
215
208
|
var dataUrl = _ref.dataUrl,
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
209
|
+
expectedNode = _ref.expectedNode,
|
|
210
|
+
expectedStructure = _ref.expectedStructure,
|
|
211
|
+
name = _ref.name;
|
|
219
212
|
context("with ".concat(name), function () {
|
|
220
|
-
it("loads the data from the url", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/
|
|
221
|
-
return
|
|
222
|
-
while (1) {
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
case 4:
|
|
235
|
-
case "end":
|
|
236
|
-
return _context.stop();
|
|
237
|
-
}
|
|
213
|
+
it("loads the data from the url", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
214
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
215
|
+
while (1) switch (_context.prev = _context.next) {
|
|
216
|
+
case 0:
|
|
217
|
+
given.$tree.tree({
|
|
218
|
+
dataUrl: dataUrl
|
|
219
|
+
});
|
|
220
|
+
_context.next = 3;
|
|
221
|
+
return _dom.screen.findByText(expectedNode);
|
|
222
|
+
case 3:
|
|
223
|
+
expect(given.$tree).toHaveTreeStructure(expectedStructure);
|
|
224
|
+
case 4:
|
|
225
|
+
case "end":
|
|
226
|
+
return _context.stop();
|
|
238
227
|
}
|
|
239
228
|
}, _callee);
|
|
240
229
|
})));
|
|
@@ -285,15 +274,12 @@ describe("onCreateLi", function () {
|
|
|
285
274
|
});
|
|
286
275
|
describe("onGetStateFromStorage and onSetStateFromStorage", function () {
|
|
287
276
|
var savedState = "";
|
|
288
|
-
|
|
289
277
|
var setState = function setState(state) {
|
|
290
278
|
savedState = state;
|
|
291
279
|
};
|
|
292
|
-
|
|
293
280
|
var getState = function getState() {
|
|
294
281
|
return savedState;
|
|
295
282
|
};
|
|
296
|
-
|
|
297
283
|
var given = (0, _givens["default"])();
|
|
298
284
|
given("initialState", function () {
|
|
299
285
|
return "";
|
|
@@ -351,29 +337,33 @@ describe("onLoadFailed", function () {
|
|
|
351
337
|
return $("#tree1");
|
|
352
338
|
});
|
|
353
339
|
context("when the loading fails", function () {
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
server = (0, _node.setupServer)(_msw.rest.get("/tree/", function (_request, response, ctx) {
|
|
340
|
+
beforeEach(function () {
|
|
341
|
+
server.use(_msw.rest.get("/tree/", function (_request, response, ctx) {
|
|
357
342
|
return response(ctx.status(500), ctx.body("Internal server error"));
|
|
358
343
|
}));
|
|
359
|
-
server.listen();
|
|
360
|
-
});
|
|
361
|
-
afterAll(function () {
|
|
362
|
-
var _server2;
|
|
363
|
-
|
|
364
|
-
(_server2 = server) === null || _server2 === void 0 ? void 0 : _server2.close();
|
|
365
|
-
});
|
|
366
|
-
it("calls onLoadFailed", function () {
|
|
367
|
-
return new Promise(function (done) {
|
|
368
|
-
given.$tree.tree({
|
|
369
|
-
dataUrl: "/tree/",
|
|
370
|
-
onLoadFailed: function onLoadFailed(jqXHR) {
|
|
371
|
-
expect(jqXHR.status).toBe(500);
|
|
372
|
-
done();
|
|
373
|
-
}
|
|
374
|
-
});
|
|
375
|
-
});
|
|
376
344
|
});
|
|
345
|
+
it("calls onLoadFailed", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
346
|
+
var onLoadFailed;
|
|
347
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
348
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
349
|
+
case 0:
|
|
350
|
+
onLoadFailed = jest.fn();
|
|
351
|
+
given.$tree.tree({
|
|
352
|
+
dataUrl: "/tree/",
|
|
353
|
+
onLoadFailed: onLoadFailed
|
|
354
|
+
});
|
|
355
|
+
_context2.next = 4;
|
|
356
|
+
return (0, _dom.waitFor)(function () {
|
|
357
|
+
expect(onLoadFailed).toHaveBeenCalledWith(expect.objectContaining({
|
|
358
|
+
status: 500
|
|
359
|
+
}));
|
|
360
|
+
});
|
|
361
|
+
case 4:
|
|
362
|
+
case "end":
|
|
363
|
+
return _context2.stop();
|
|
364
|
+
}
|
|
365
|
+
}, _callee2);
|
|
366
|
+
})));
|
|
377
367
|
});
|
|
378
368
|
});
|
|
379
369
|
describe("rtl", function () {
|