@wix/design-system
Version:
@wix/design-system
492 lines • 12.9 kB
JavaScript
import _extends from "@babel/runtime/helpers/extends";
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
import _createClass from "@babel/runtime/helpers/createClass";
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
import _inherits from "@babel/runtime/helpers/inherits";
var _jsxFileName = "/home/builduser/work/57e038ea7326c1ec/packages/wix-design-system/dist/esm/Dropdown/test/Dropdown.visual.jsx",
_this = this;
import _regeneratorRuntime from "@babel/runtime/regenerator";
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
import React from 'react';
import { storiesOf } from '@storybook/react';
import TextButton from '../../TextButton';
import Button from '../../Button';
import Dropdown from '../index';
import FormField from '../../FormField';
import { Layout, Cell } from '../../Layout';
import { clickElement } from '../../utils/test-utils/visual';
var interactiveDataHook = 'interactive-dropdown';
var inputDataHook = 'wsr-input';
var InteractiveEyeTest = /*#__PURE__*/function (_React$Component) {
function InteractiveEyeTest() {
_classCallCheck(this, InteractiveEyeTest);
return _callSuper(this, InteractiveEyeTest, arguments);
}
_inherits(InteractiveEyeTest, _React$Component);
return _createClass(InteractiveEyeTest, [{
key: "componentDidMount",
value: function () {
var _componentDidMount = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
return _regeneratorRuntime.wrap(function _callee$(_context) {
while (1) switch (_context.prev = _context.next) {
case 0:
this.props.componentDidMount();
case 1:
case "end":
return _context.stop();
}
}, _callee, this);
}));
function componentDidMount() {
return _componentDidMount.apply(this, arguments);
}
return componentDidMount;
}()
}, {
key: "render",
value: function render() {
return /*#__PURE__*/React.createElement(Layout, {
__self: this,
__source: {
fileName: _jsxFileName,
lineNumber: 19,
columnNumber: 7
}
}, /*#__PURE__*/React.createElement(Cell, {
__self: this,
__source: {
fileName: _jsxFileName,
lineNumber: 20,
columnNumber: 9
}
}, /*#__PURE__*/React.createElement(Dropdown, _extends({
dataHook: interactiveDataHook
}, this.props, {
__self: this,
__source: {
fileName: _jsxFileName,
lineNumber: 21,
columnNumber: 11
}
}))));
}
}]);
}(React.Component);
var DropdownWithFormFieldStatus = /*#__PURE__*/function (_React$Component2) {
function DropdownWithFormFieldStatus() {
_classCallCheck(this, DropdownWithFormFieldStatus);
return _callSuper(this, DropdownWithFormFieldStatus, arguments);
}
_inherits(DropdownWithFormFieldStatus, _React$Component2);
return _createClass(DropdownWithFormFieldStatus, [{
key: "render",
value: function render() {
return /*#__PURE__*/React.createElement(Layout, {
__self: this,
__source: {
fileName: _jsxFileName,
lineNumber: 31,
columnNumber: 7
}
}, /*#__PURE__*/React.createElement(Cell, {
__self: this,
__source: {
fileName: _jsxFileName,
lineNumber: 32,
columnNumber: 9
}
}, /*#__PURE__*/React.createElement(FormField, {
status: this.props.status,
statusMessage: this.props.statusMessage,
__self: this,
__source: {
fileName: _jsxFileName,
lineNumber: 33,
columnNumber: 11
}
}, /*#__PURE__*/React.createElement(Dropdown, {
placeholder: "choose",
__self: this,
__source: {
fileName: _jsxFileName,
lineNumber: 37,
columnNumber: 13
}
})), /*#__PURE__*/React.createElement(Dropdown, {
status: this.props.status,
placeholder: "choose",
__self: this,
__source: {
fileName: _jsxFileName,
lineNumber: 39,
columnNumber: 11
}
})));
}
}]);
}(React.Component);
var interactiveTests = [{
describe: 'Examples',
its: [{
it: 'simple',
componentDidMount: function componentDidMount() {
clickElement(inputDataHook);
},
props: {
options: [{
id: 0,
value: 'Left'
}, {
id: 1,
value: 'Right'
}, {
id: 2,
value: 'Ambidextrous'
}]
}
}, {
it: 'group',
componentDidMount: function componentDidMount() {
clickElement(inputDataHook);
},
props: {
options: [{
id: 'first title',
value: 'title #1',
title: true
}, {
id: 1,
value: 'Option 1'
}, {
id: 'title',
value: 'title #2',
title: true
}, {
id: 2,
value: 'Option 2'
}, {
id: 4,
value: 'Option 3'
}]
}
}, {
it: 'divider',
componentDidMount: function componentDidMount() {
clickElement(inputDataHook);
},
props: {
options: [{
id: 0,
value: 'Left'
}, {
id: 1,
value: 'Right'
}, {
id: -99,
value: '-'
}, {
id: 2,
value: 'Ambidextrous'
}]
}
}, {
it: 'footer',
componentDidMount: function componentDidMount() {
clickElement(inputDataHook);
},
props: {
fixedFooter: /*#__PURE__*/React.createElement("div", {
style: {
display: 'flex',
justifyContent: 'space-around',
padding: '15px 24px',
alignItems: 'center'
},
__self: this,
__source: {
fileName: _jsxFileName,
lineNumber: 99,
columnNumber: 13
}
}, /*#__PURE__*/React.createElement(TextButton, {
skin: "dark",
underline: "always",
__self: this,
__source: {
fileName: _jsxFileName,
lineNumber: 107,
columnNumber: 15
}
}, "Clear"), /*#__PURE__*/React.createElement(Button, {
__self: this,
__source: {
fileName: _jsxFileName,
lineNumber: 110,
columnNumber: 15
}
}, "Apply")),
options: [{
id: 0,
value: 'Left'
}, {
id: 1,
value: 'Right'
}, {
id: 2,
value: 'Ambidextrous'
}]
}
}, {
it: 'header',
componentDidMount: function componentDidMount() {
clickElement(inputDataHook);
},
props: {
fixedHeader: /*#__PURE__*/React.createElement("div", {
style: {
display: 'flex',
justifyContent: 'space-around',
padding: '15px 24px',
alignItems: 'center'
},
__self: this,
__source: {
fileName: _jsxFileName,
lineNumber: 127,
columnNumber: 13
}
}, /*#__PURE__*/React.createElement(TextButton, {
skin: "dark",
underline: "always",
__self: this,
__source: {
fileName: _jsxFileName,
lineNumber: 135,
columnNumber: 15
}
}, "Clear"), /*#__PURE__*/React.createElement(Button, {
__self: this,
__source: {
fileName: _jsxFileName,
lineNumber: 138,
columnNumber: 15
}
}, "Apply")),
options: [{
id: 0,
value: 'Left'
}, {
id: 1,
value: 'Right'
}, {
id: 2,
value: 'Ambidextrous'
}]
}
}, {
it: 'error',
componentDidMount: function componentDidMount() {
clickElement(inputDataHook);
},
props: {
status: 'error',
options: [{
id: 0,
value: 'Left'
}, {
id: 1,
value: 'Right'
}, {
id: 2,
value: 'Ambidextrous'
}]
}
}, {
it: 'disabled',
componentDidMount: function componentDidMount() {
clickElement(inputDataHook);
},
props: {
disabled: true,
options: [{
id: 0,
value: 'Left'
}, {
id: 1,
value: 'Right'
}, {
id: 2,
value: 'Ambidextrous'
}]
}
}, {
it: 'readOnly',
props: {
readOnly: true
}
}, {
it: 'loader',
componentDidMount: function componentDidMount() {
clickElement(inputDataHook);
},
props: {
options: [],
hasMore: true,
infiniteScroll: true
}
}]
}];
var DropdownWithFormFieldStatusTests = [{
describe: 'DropdownWithFormField',
its: [{
it: 'error',
props: {
options: [],
status: 'error',
statusMessage: 'This is an error'
}
}, {
it: 'warning',
props: {
options: [],
status: 'warning',
statusMessage: 'This is a warning'
}
}]
}];
var DropdownSizeTests = [{
describe: 'Sizes',
its: [{
it: 'small',
componentDidMount: function componentDidMount() {
clickElement(inputDataHook);
},
props: {
size: 'small',
options: [{
id: 0,
value: 'Small Size Option 1'
}, {
id: 1,
value: 'Small Size Option 2'
}, {
id: 2,
value: 'Small Size Option 3'
}]
}
}, {
it: 'medium',
componentDidMount: function componentDidMount() {
clickElement(inputDataHook);
},
props: {
size: 'medium',
options: [{
id: 0,
value: 'Medium Size Option 1'
}, {
id: 1,
value: 'Medium Size Option 2'
}, {
id: 2,
value: 'Medium Size Option 3'
}]
}
}, {
it: 'large',
componentDidMount: function componentDidMount() {
clickElement(inputDataHook);
},
props: {
size: 'large',
options: [{
id: 0,
value: 'Large Size Option 1'
}, {
id: 1,
value: 'Large Size Option 2'
}, {
id: 2,
value: 'Large Size Option 3'
}]
}
}, {
it: 'default (undefined)',
componentDidMount: function componentDidMount() {
clickElement(inputDataHook);
},
props: {
options: [{
id: 0,
value: 'Default Size Option 1'
}, {
id: 1,
value: 'Default Size Option 2'
}, {
id: 2,
value: 'Default Size Option 3'
}]
}
}]
}];
interactiveTests.forEach(function (_ref) {
var describe = _ref.describe,
its = _ref.its;
its.forEach(function (_ref2) {
var it = _ref2.it,
props = _ref2.props,
componentDidMount = _ref2.componentDidMount;
storiesOf("Dropdown".concat(describe ? '/' + describe : ''), module).add(it, function () {
return /*#__PURE__*/React.createElement(InteractiveEyeTest, _extends({}, props, {
componentDidMount: componentDidMount,
__self: _this,
__source: {
fileName: _jsxFileName,
lineNumber: 289,
columnNumber: 9
}
}));
});
});
});
DropdownWithFormFieldStatusTests.forEach(function (_ref3) {
var describe = _ref3.describe,
its = _ref3.its;
its.forEach(function (_ref4) {
var it = _ref4.it,
props = _ref4.props;
storiesOf("Dropdown".concat(describe ? '/' + describe : ''), module).add(it, function () {
return /*#__PURE__*/React.createElement(DropdownWithFormFieldStatus, _extends({}, props, {
__self: _this,
__source: {
fileName: _jsxFileName,
lineNumber: 299,
columnNumber: 13
}
}));
});
});
});
DropdownSizeTests.forEach(function (_ref5) {
var describe = _ref5.describe,
its = _ref5.its;
its.forEach(function (_ref6) {
var it = _ref6.it,
props = _ref6.props,
componentDidMount = _ref6.componentDidMount;
storiesOf("Dropdown".concat(describe ? '/' + describe : ''), module).add(it, function () {
return /*#__PURE__*/React.createElement(InteractiveEyeTest, _extends({}, props, {
componentDidMount: componentDidMount,
__self: _this,
__source: {
fileName: _jsxFileName,
lineNumber: 309,
columnNumber: 9
}
}));
});
});
});