UNPKG

@wix/design-system

Version:

@wix/design-system

169 lines 4.98 kB
import _extends from "@babel/runtime/helpers/extends"; import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties"; var _excluded = ["onDone"]; var _jsxFileName = "/home/builduser/work/57e038ea7326c1ec/packages/wix-design-system/dist/esm/ImageViewer/test/ImageViewer.visual.jsx", _this = this; import React from 'react'; import { visualize, story, snap } from 'storybook-snapper'; import ImageViewer from '..'; import FormField from '../../FormField'; var imageUrl = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAYAAABw4pVUAAACTklEQVR4Xu2dMW4bQRTFonPkHCly/8JFzuFzxIhLCcgnBvuJtUHXnHkrUpAKFX68//7190d/tzHwKMhtWnw+SEHu1aMgN+vxGuTn25/H3R7yOz/P81fGy0dWQdz8BXF9j2sFGRW5QEFc3+NaQUZFLlAQ1/e4VpBRkQsUxPU9rhVkVOQCBXF9j2sFGRW5QEFc3+NaQUZFLlAQ1/e4VpBRkQsUxPU9rmlBvvNv9Vf+ZlSQ8T07AwWZHalEQVTd89iXDDK/rGuI58/gK2Vd84T/v0X7DjFezL+Nglim4U5BoCgLK4hlGu4UBIqysIJYpuFOQaAoCyuIZRruFASKsrCCWKbhTkGgKAsriGUa7hQEirKwglim4U5BoCgLK4hlGu4UBIqysIJYpuFOQaAoCyuIZRruFASKsrCCWKbhTkGgKAsriGUa7hQEirKwglim4U5BoCgLK4hlGu4UBIqysIJYpuFOQaAoCyuIZRruFASKsrCCWKbhTkGgKAsriGUa7hQEirKwglim4U5BoCgLK4hlGu4UBIqysIJYpuFOQaAoCyuIZRruFASKsrCCWKbhTkGgKAsriGUa7hQEirKwglim4U5BoCgLK4hlGu4UBIqysIJYpuFOQaCoMGbg+Q3V/8Jl3taogqypPbu4IGfe1k4VZE3t2cUFOfO2dqoga2rPLi7Imbe1UwVZU3t2cUHOvK2dKsia2rOLC3Lmbe1UQdbUnl1ckDNva6cKsqb27OKCnHlbOzUGWVvuYmTg5fcQdCpozUBB1tSeXVyQM29rpz4AiuhEmroNH+YAAAAASUVORK5CYII='; var tests = [{ description: 'standard', its: [{ it: 'disabled with an image', props: { imageUrl: imageUrl, disabled: true } }, { it: 'disabled without an image', props: { disabled: true } }, { it: 'loading state (add image should not be visible)', props: { imageUrl: imageUrl }, skipDone: true }] }, { description: 'with status', its: [{ it: 'error', props: { status: 'error' } }, { it: 'warning', props: { status: 'warning' } }, { it: 'loading', props: { status: 'loading' } }, { it: 'disabled with a status', props: { status: 'error', disabled: true } }] }, { description: 'with fit', its: [{ it: 'cover', props: { imageUrl: imageUrl, fit: 'cover' } }, { it: 'contain', props: { imageUrl: imageUrl, fit: 'contain' } }] }]; var formFieldStatusTests = [{ description: 'Form field status', its: [{ it: 'Error', props: { status: 'error', statusMessage: 'This is error' } }, { it: 'Warning', props: { status: 'warning', statusMessage: 'This is warning' } }, { it: 'Loading', props: { status: 'loading', statusMessage: 'This is loading' } }] }]; var AsyncStoryWrapper = function AsyncStoryWrapper(_ref) { var onDone = _ref.onDone, rest = _objectWithoutProperties(_ref, _excluded); return /*#__PURE__*/React.createElement(ImageViewer, _extends({ onImageLoad: onDone }, rest, { __self: _this, __source: { fileName: _jsxFileName, lineNumber: 116, columnNumber: 3 } })); }; visualize('ImageViewer', function () { tests.forEach(function (_ref2) { var description = _ref2.description, its = _ref2.its; story(description, function () { its.forEach(function (_ref3) { var it = _ref3.it, props = _ref3.props, skipDone = _ref3.skipDone; return skipDone ? snap(it, function () { return /*#__PURE__*/React.createElement(ImageViewer, _extends({}, props, { __self: _this, __source: { fileName: _jsxFileName, lineNumber: 124, columnNumber: 28 } })); }) : snap(it, function (done) { return /*#__PURE__*/React.createElement(AsyncStoryWrapper, _extends({}, props, { onDone: done, __self: _this, __source: { fileName: _jsxFileName, lineNumber: 125, columnNumber: 30 } })); }); }); }); }); }); visualize('ImageViewer', function () { formFieldStatusTests.forEach(function (_ref4) { var description = _ref4.description, its = _ref4.its; story(description, function () { its.forEach(function (_ref5) { var it = _ref5.it, props = _ref5.props; return snap(it, function (done) { return /*#__PURE__*/React.createElement(FormField, _extends({}, props, { __self: _this, __source: { fileName: _jsxFileName, lineNumber: 136, columnNumber: 11 } }), /*#__PURE__*/React.createElement(ImageViewer, { onImageLoad: done, __self: _this, __source: { fileName: _jsxFileName, lineNumber: 137, columnNumber: 13 } })); }); }); }); }); });