UNPKG

wix-style-react

Version:
384 lines (326 loc) • 13.2 kB
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; var _this = this; function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; } import { scrollToElement, waitForVisibilityOf } from 'wix-ui-test-utils/protractor'; import autoExampleDriver from 'wix-storybook-utils/AutoExampleDriver'; import { eyesItInstance } from '../../test/utils/eyes-it'; import { createStoryUrl, createTestStoryUrl } from '../../test/utils/storybook-helpers'; import { storySettings, testStories } from '../../stories/Box/storySettings'; import { boxTestkitFactory } from '../../testkit/protractor'; var eyes = eyesItInstance(); describe('Box', function () { var storyUrl = createStoryUrl({ kind: storySettings.category, story: storySettings.storyName }); var createDriver = function () { var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() { var dataHook = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : storySettings.dataHook; var driver; return regeneratorRuntime.wrap(function _callee$(_context) { while (1) { switch (_context.prev = _context.next) { case 0: driver = boxTestkitFactory({ dataHook: dataHook }); _context.t0 = waitForVisibilityOf; _context.next = 4; return driver.element(); case 4: _context.t1 = _context.sent; _context.t2 = 'Cannot find <Box/> component with dataHook of ' + dataHook; _context.next = 8; return (0, _context.t0)(_context.t1, _context.t2); case 8: _context.t3 = scrollToElement; _context.next = 11; return driver.element(); case 11: _context.t4 = _context.sent; _context.next = 14; return (0, _context.t3)(_context.t4); case 14: return _context.abrupt('return', driver); case 15: case 'end': return _context.stop(); } } }, _callee, _this); })); return function createDriver() { return _ref.apply(this, arguments); }; }(); describe('AutoExample', function () { beforeAll(_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() { return regeneratorRuntime.wrap(function _callee2$(_context2) { while (1) { switch (_context2.prev = _context2.next) { case 0: _context2.next = 2; return browser.get(storyUrl); case 2: return _context2.abrupt('return', _context2.sent); case 3: case 'end': return _context2.stop(); } } }, _callee2, _this); }))); afterEach(_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3() { return regeneratorRuntime.wrap(function _callee3$(_context3) { while (1) { switch (_context3.prev = _context3.next) { case 0: _context3.next = 2; return autoExampleDriver.remount(); case 2: return _context3.abrupt('return', _context3.sent); case 3: case 'end': return _context3.stop(); } } }, _callee3, _this); }))); eyes.it('should be rendered', _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4() { return regeneratorRuntime.wrap(function _callee4$(_context4) { while (1) { switch (_context4.prev = _context4.next) { case 0: _context4.next = 2; return createDriver(); case 2: case 'end': return _context4.stop(); } } }, _callee4, _this); }))); eyes.it('should be rendered as an inline element', _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee5() { return regeneratorRuntime.wrap(function _callee5$(_context5) { while (1) { switch (_context5.prev = _context5.next) { case 0: _context5.next = 2; return autoExampleDriver.setProps({ inline: true }); case 2: _context5.next = 4; return createDriver(); case 4: case 'end': return _context5.stop(); } } }, _callee5, _this); }))); describe('Alignment', function () { eyes.it('should be aligned horizontally to right', _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee6() { return regeneratorRuntime.wrap(function _callee6$(_context6) { while (1) { switch (_context6.prev = _context6.next) { case 0: _context6.next = 2; return autoExampleDriver.setProps({ align: 'right' }); case 2: _context6.next = 4; return createDriver(); case 4: case 'end': return _context6.stop(); } } }, _callee6, _this); }))); eyes.it('should be aligned vertically to bottom', _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee7() { return regeneratorRuntime.wrap(function _callee7$(_context7) { while (1) { switch (_context7.prev = _context7.next) { case 0: _context7.next = 2; return autoExampleDriver.setProps({ verticalAlign: 'bottom' }); case 2: _context7.next = 4; return createDriver(); case 4: case 'end': return _context7.stop(); } } }, _callee7, _this); }))); }); describe('Spacing', function () { eyes.it('should be rendered with margin', _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee8() { return regeneratorRuntime.wrap(function _callee8$(_context8) { while (1) { switch (_context8.prev = _context8.next) { case 0: _context8.next = 2; return autoExampleDriver.setProps({ margin: 2 }); case 2: _context8.next = 4; return createDriver(); case 4: case 'end': return _context8.stop(); } } }, _callee8, _this); }))); eyes.it('should be rendered with padding', _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee9() { return regeneratorRuntime.wrap(function _callee9$(_context9) { while (1) { switch (_context9.prev = _context9.next) { case 0: _context9.next = 2; return autoExampleDriver.setProps({ padding: '3px 4px' }); case 2: _context9.next = 4; return createDriver(); case 4: case 'end': return _context9.stop(); } } }, _callee9, _this); }))); }); describe('Sizing', function () { eyes.it('should be rendered with minHeight', _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee10() { return regeneratorRuntime.wrap(function _callee10$(_context10) { while (1) { switch (_context10.prev = _context10.next) { case 0: _context10.next = 2; return autoExampleDriver.setProps({ minHeight: '50px' }); case 2: _context10.next = 4; return createDriver(); case 4: case 'end': return _context10.stop(); } } }, _callee10, _this); }))); eyes.it('should be rendered with maxWidth', _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee11() { return regeneratorRuntime.wrap(function _callee11$(_context11) { while (1) { switch (_context11.prev = _context11.next) { case 0: _context11.next = 2; return autoExampleDriver.setProps({ maxWidth: '100px' }); case 2: _context11.next = 4; return createDriver(); case 4: case 'end': return _context11.stop(); } } }, _callee11, _this); }))); }); describe('Styling', function () { eyes.it('should be rendered with color', _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee12() { return regeneratorRuntime.wrap(function _callee12$(_context12) { while (1) { switch (_context12.prev = _context12.next) { case 0: _context12.next = 2; return autoExampleDriver.setProps({ color: 'G00' }); case 2: _context12.next = 4; return createDriver(); case 4: case 'end': return _context12.stop(); } } }, _callee12, _this); }))); eyes.it('should be rendered with backgroundColor', _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee13() { return regeneratorRuntime.wrap(function _callee13$(_context13) { while (1) { switch (_context13.prev = _context13.next) { case 0: _context13.next = 2; return autoExampleDriver.setProps({ backgroundColor: '#3899ec' }); case 2: _context13.next = 4; return createDriver(); case 4: case 'end': return _context13.stop(); } } }, _callee13, _this); }))); eyes.it('should be rendered with blue border color on the top, green color on the right, red color on the bottom and gray color on the left', _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee14() { return regeneratorRuntime.wrap(function _callee14$(_context14) { while (1) { switch (_context14.prev = _context14.next) { case 0: _context14.next = 2; return autoExampleDriver.setProps({ border: '1px solid #2b81cb', borderRightColor: 'G00', borderBottomColor: '#d6453d', borderLeftColor: 'D50' }); case 2: _context14.next = 4; return createDriver(); case 4: case 'end': return _context14.stop(); } } }, _callee14, _this); }))); }); }); describe('Examples', function () { var testStoryUrl = function testStoryUrl(testName) { return createTestStoryUrl(_extends({}, storySettings, { testName: testName })); }; var checkTestStory = function () { var _ref15 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee15(testName) { return regeneratorRuntime.wrap(function _callee15$(_context15) { while (1) { switch (_context15.prev = _context15.next) { case 0: _context15.next = 2; return browser.get(testStoryUrl(testName)); case 2: _context15.next = 4; return eyes.checkWindow(testName); case 4: case 'end': return _context15.stop(); } } }, _callee15, _this); })); return function checkTestStory(_x2) { return _ref15.apply(this, arguments); }; }(); eyes.it('should render a box that contains multiple boxes', _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee16() { return regeneratorRuntime.wrap(function _callee16$(_context16) { while (1) { switch (_context16.prev = _context16.next) { case 0: _context16.next = 2; return checkTestStory(testStories.multipleBoxes); case 2: case 'end': return _context16.stop(); } } }, _callee16, _this); }))); }); });