@wix/design-system
Version:
@wix/design-system
247 lines (246 loc) • 6.12 kB
JavaScript
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _react = _interopRequireDefault(require("react"));
var _react2 = require("@storybook/react");
var _NestableList = _interopRequireDefault(require("../NestableList"));
var _jsxFileName = "/home/builduser/work/57e038ea7326c1ec/packages/wix-design-system/dist/cjs/NestableList/test/NestableList.visual.jsx",
_this = void 0;
var counter = 0;
var getSimpleExampleItems = function getSimpleExampleItems() {
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var draggable = options.draggable,
addItemLabel = options.addItemLabel,
dragDisabled = options.dragDisabled,
hideDragHandle = options.hideDragHandle;
return Array.from(new Array(2)).map(function (_, index) {
return {
id: counter++,
options: [{
value: "Node ".concat(index)
}],
draggable: draggable,
hideDragHandle: hideDragHandle,
dragDisabled: dragDisabled,
addItemLabel: addItemLabel ? "".concat(addItemLabel, " to Node ").concat(index) : undefined,
children: [{
id: counter++,
options: [{
value: "Node ".concat(index, " child")
}],
draggable: draggable,
dragDisabled: dragDisabled,
hideDragHandle: hideDragHandle
}]
};
});
};
var commonProps = {
// use for repeated props across the tests (e.g. {buttonText: 'example'})
};
var tests = [{
describe: 'sanity',
// prop name (e.g. size)
its: [{
it: 'default',
// prop variation (e.g. small)
props: {
items: getSimpleExampleItems()
}
}, {
it: 'With bottom border',
// prop variation (e.g. small)
props: {
items: getSimpleExampleItems(),
withBottomBorder: true
}
}, {
it: 'With add button',
// prop variation (e.g. small)
props: {
maxDepth: 2,
items: getSimpleExampleItems(),
addItemLabel: 'Add item'
}
}, {
it: 'With dragDisable icon',
// prop variation (e.g. small)
props: {
maxDepth: 2,
items: getSimpleExampleItems({
draggable: true,
dragDisabled: true
})
}
}, {
it: 'Draggable without dragHandle',
props: {
maxDepth: 2,
items: getSimpleExampleItems({
draggable: true,
hideDragHandle: true
})
}
}, {
it: 'Dragging disabled',
// prop variation (e.g. small)
props: {
maxDepth: 2,
items: getSimpleExampleItems({
draggable: false
})
}
}, {
it: 'Static (non-draggable)',
props: {
maxDepth: 2,
items: getSimpleExampleItems({
draggable: false,
hideDragHandle: true
})
}
}, {
it: 'Without dividers',
props: {
dividers: false,
items: getSimpleExampleItems()
}
}, {
it: 'Without dividers, with bottom border',
props: {
dividers: false,
withBottomBorder: true,
items: getSimpleExampleItems()
}
}, {
it: 'Small indent',
props: {
indentSize: 'small',
items: getSimpleExampleItems()
}
}, {
it: 'Small indent, without dividers',
props: {
indentSize: 'small',
dividers: false,
items: getSimpleExampleItems()
}
}, {
it: 'Medium indent',
props: {
indentSize: 'medium',
items: getSimpleExampleItems()
}
}, {
it: 'Medium indent, without dividers',
props: {
indentSize: 'medium',
dividers: false,
items: getSimpleExampleItems()
}
}, {
it: 'Expandable',
props: {
items: [{
id: 'item-1',
options: [{
value: 'Item 1'
}]
}, {
id: 'item-2',
expandable: true,
expanded: true,
isCollapsed: false,
options: [{
value: 'Show and hide children'
}],
children: [{
id: 'item-2-child-1',
options: [{
value: 'Child 1'
}]
}, {
id: 'item-2-child-2',
expandable: true,
expanded: true,
options: [{
value: 'Child 2'
}],
children: [{
id: 'item-2-child-2-child-1',
options: [{
value: 'Child 3'
}]
}]
}]
}, {
id: 'item-3',
options: [{
value: 'Item 3'
}]
}]
}
}, {
it: 'Without dividers, without hierarchy indicator, small indent, small drag handle size',
props: {
dividers: false,
indentSize: 'small',
dragHandleSize: 'small',
hierarchyIndicator: false,
items: getSimpleExampleItems()
}
}, {
it: 'Static and Draggable alignment',
props: {
items: [{
id: 'item-1',
options: [{
value: 'Item 1'
}]
}, {
id: 'item-2',
options: [{
value: 'Item 2'
}],
draggable: false,
hideDragHandle: true,
children: [{
id: 'item-2-child-1',
options: [{
value: 'Child 1'
}],
draggable: false,
hideDragHandle: true
}, {
id: 'item-2-child-2',
options: [{
value: 'Child 2'
}]
}]
}, {
id: 'item-3',
options: [{
value: 'Item 3'
}]
}]
}
}]
}];
tests.forEach(function (_ref) {
var describe = _ref.describe,
its = _ref.its;
its.forEach(function (_ref2) {
var it = _ref2.it,
props = _ref2.props;
(0, _react2.storiesOf)("".concat(_NestableList["default"].displayName).concat(describe ? '/' + describe : ''), module).add(it, function () {
return /*#__PURE__*/_react["default"].createElement(_NestableList["default"], (0, _extends2["default"])({}, commonProps, props, {
__self: _this,
__source: {
fileName: _jsxFileName,
lineNumber: 236,
columnNumber: 21
}
}));
});
});
});