wix-style-react
Version:
wix-style-react
174 lines (141 loc) • 5.48 kB
JavaScript
;
var waitForFetching = function () {
var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
_context.next = 2;
return (0, _reactHelpers.sleep)(700);
case 2:
case 'end':
return _context.stop();
}
}
}, _callee, this);
}));
return function waitForFetching() {
return _ref.apply(this, arguments);
};
}();
var _eyes = require('eyes.it');
var _eyes2 = _interopRequireDefault(_eyes);
var _reactHelpers = require('wix-ui-test-utils/react-helpers');
var _protractor = require('../../testkit/protractor');
var _protractor2 = require('wix-ui-test-utils/protractor');
var _protractor3 = require('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"); }); }; }
describe('DropdownLayout', function () {
var driver = void 0;
var storyUrl = (0, _protractor2.createStoryUrl)({
kind: '11. Pickers and Selectors',
story: '11.1 DropdownLayout',
withExamples: false
});
beforeAll(_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
return regeneratorRuntime.wrap(function _callee2$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
_protractor3.browser.get(storyUrl);
driver = (0, _protractor.dropdownLayoutTestkitFactory)({
dataHook: 'infinite-scroll-dropdownLayout'
});
case 2:
case 'end':
return _context2.stop();
}
}
}, _callee2, undefined);
})));
beforeEach(_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 (0, _protractor2.waitForVisibilityOf)(driver.element(), 'Cant find infinite scroll dropdownLayout');
case 2:
_context3.next = 4;
return waitForFetching();
case 4:
_context3.next = 6;
return (0, _protractor2.scrollToElement)(driver.element());
case 6:
case 'end':
return _context3.stop();
}
}
}, _callee3, undefined);
})));
_eyes2.default.it('should render items properly', _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4() {
return regeneratorRuntime.wrap(function _callee4$(_context4) {
while (1) {
switch (_context4.prev = _context4.next) {
case 0:
_context4.t0 = expect;
_context4.next = 3;
return driver.getDropdownItem(0);
case 3:
_context4.t1 = _context4.sent;
(0, _context4.t0)(_context4.t1).toEqual('options 0');
case 5:
case 'end':
return _context4.stop();
}
}
}, _callee4, undefined);
})));
_eyes2.default.it('should add more items from server when scrolling down', _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee5() {
return regeneratorRuntime.wrap(function _callee5$(_context5) {
while (1) {
switch (_context5.prev = _context5.next) {
case 0:
_context5.t0 = expect;
_context5.next = 3;
return driver.getDropdownItemsCount();
case 3:
_context5.t1 = _context5.sent;
(0, _context5.t0)(_context5.t1).toEqual(15);
_context5.next = 7;
return driver.scrollToElement(14);
case 7:
_context5.next = 9;
return waitForFetching();
case 9:
_context5.t2 = expect;
_context5.next = 12;
return driver.getDropdownItemsCount();
case 12:
_context5.t3 = _context5.sent;
(0, _context5.t2)(_context5.t3).toEqual(30);
case 14:
case 'end':
return _context5.stop();
}
}
}, _callee5, undefined);
})));
_eyes2.default.it('should show loader', _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 driver.scrollToElement(14);
case 2:
_context6.t0 = expect;
_context6.next = 5;
return driver.loaderExists();
case 5:
_context6.t1 = _context6.sent;
(0, _context6.t0)(_context6.t1).toBeTruthy();
case 7:
case 'end':
return _context6.stop();
}
}
}, _callee6, undefined);
})));
});