UNPKG

wix-style-react

Version:
392 lines (328 loc) • 13.6 kB
'use strict'; 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 _protractor = require('wix-ui-test-utils/protractor'); var _AutoExampleDriver = require('wix-storybook-utils/AutoExampleDriver'); var _AutoExampleDriver2 = _interopRequireDefault(_AutoExampleDriver); var _eyesIt = require('../../test/utils/eyes-it'); var _storybookHelpers = require('../../test/utils/storybook-helpers'); var _storySettings = require('../../stories/Box/storySettings'); var _protractor2 = require('../../testkit/protractor'); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 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"); }); }; } var eyes = (0, _eyesIt.eyesItInstance)(); describe('Box', function () { var storyUrl = (0, _storybookHelpers.createStoryUrl)({ kind: _storySettings.storySettings.category, story: _storySettings.storySettings.storyName }); var createDriver = function () { var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() { var dataHook = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _storySettings.storySettings.dataHook; var driver; return regeneratorRuntime.wrap(function _callee$(_context) { while (1) { switch (_context.prev = _context.next) { case 0: driver = (0, _protractor2.boxTestkitFactory)({ dataHook: dataHook }); _context.t0 = _protractor.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 = _protractor.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, undefined); })); 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, undefined); }))); 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 _AutoExampleDriver2.default.remount(); case 2: return _context3.abrupt('return', _context3.sent); case 3: case 'end': return _context3.stop(); } } }, _callee3, undefined); }))); 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, undefined); }))); 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 _AutoExampleDriver2.default.setProps({ inline: true }); case 2: _context5.next = 4; return createDriver(); case 4: case 'end': return _context5.stop(); } } }, _callee5, undefined); }))); 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 _AutoExampleDriver2.default.setProps({ align: 'right' }); case 2: _context6.next = 4; return createDriver(); case 4: case 'end': return _context6.stop(); } } }, _callee6, undefined); }))); 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 _AutoExampleDriver2.default.setProps({ verticalAlign: 'bottom' }); case 2: _context7.next = 4; return createDriver(); case 4: case 'end': return _context7.stop(); } } }, _callee7, undefined); }))); }); 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 _AutoExampleDriver2.default.setProps({ margin: 2 }); case 2: _context8.next = 4; return createDriver(); case 4: case 'end': return _context8.stop(); } } }, _callee8, undefined); }))); 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 _AutoExampleDriver2.default.setProps({ padding: '3px 4px' }); case 2: _context9.next = 4; return createDriver(); case 4: case 'end': return _context9.stop(); } } }, _callee9, undefined); }))); }); 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 _AutoExampleDriver2.default.setProps({ minHeight: '50px' }); case 2: _context10.next = 4; return createDriver(); case 4: case 'end': return _context10.stop(); } } }, _callee10, undefined); }))); 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 _AutoExampleDriver2.default.setProps({ maxWidth: '100px' }); case 2: _context11.next = 4; return createDriver(); case 4: case 'end': return _context11.stop(); } } }, _callee11, undefined); }))); }); 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 _AutoExampleDriver2.default.setProps({ color: 'G00' }); case 2: _context12.next = 4; return createDriver(); case 4: case 'end': return _context12.stop(); } } }, _callee12, undefined); }))); 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 _AutoExampleDriver2.default.setProps({ backgroundColor: '#3899ec' }); case 2: _context13.next = 4; return createDriver(); case 4: case 'end': return _context13.stop(); } } }, _callee13, undefined); }))); 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 _AutoExampleDriver2.default.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, undefined); }))); }); }); describe('Examples', function () { var testStoryUrl = function testStoryUrl(testName) { return (0, _storybookHelpers.createTestStoryUrl)(_extends({}, _storySettings.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, undefined); })); 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(_storySettings.testStories.multipleBoxes); case 2: case 'end': return _context16.stop(); } } }, _callee16, undefined); }))); }); });