wix-style-react
Version:
wix-style-react
167 lines (139 loc) • 5.23 kB
JavaScript
var _this = this;
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 sleep(700);
case 2:
case 'end':
return _context.stop();
}
}
}, _callee, this);
}));
return function waitForFetching() {
return _ref.apply(this, arguments);
};
}();
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 eyes from 'eyes.it';
import { sleep } from 'wix-ui-test-utils/react-helpers';
import { dropdownLayoutTestkitFactory } from '../../testkit/protractor';
import { createStoryUrl, scrollToElement, waitForVisibilityOf } from 'wix-ui-test-utils/protractor';
import { browser } from 'protractor';
describe('DropdownLayout', function () {
var driver = void 0;
var storyUrl = 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:
browser.get(storyUrl);
driver = dropdownLayoutTestkitFactory({
dataHook: 'infinite-scroll-dropdownLayout'
});
case 2:
case 'end':
return _context2.stop();
}
}
}, _callee2, _this);
})));
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 waitForVisibilityOf(driver.element(), 'Cant find infinite scroll dropdownLayout');
case 2:
_context3.next = 4;
return waitForFetching();
case 4:
_context3.next = 6;
return scrollToElement(driver.element());
case 6:
case 'end':
return _context3.stop();
}
}
}, _callee3, _this);
})));
eyes.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, _this);
})));
eyes.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, _this);
})));
eyes.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, _this);
})));
});