@roo-ui/components
Version:
124 lines (98 loc) • 3.23 kB
JavaScript
var _react = require('react');
var _react2 = _interopRequireDefault(_react);
var _jestAxe = require('jest-axe');
var _themes = require('@roo-ui/themes');
var _testUtils = require('@roo-ui/test-utils');
var _ = require('..');
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('<List />', function () {
var props = void 0;
beforeEach(function () {
props = {};
});
var tree = function tree() {
return _react2.default.createElement(
_.List,
props,
_react2.default.createElement(
_.ListItem,
null,
'Hello Item 1'
),
_react2.default.createElement(
_.ListItem,
null,
'Hello Item 2'
),
_react2.default.createElement(
_.ListItem,
null,
'Hello Item 3'
)
);
};
var render = function render() {
return (0, _testUtils.shallowWithTheme)(tree(), _themes.qantas).dive();
};
it('renders correctly', function () {
expect(render()).toMatchSnapshot();
});
it('has no accessibility errors', _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
_context.t0 = expect;
_context.next = 3;
return (0, _jestAxe.axe)(render().html());
case 3:
_context.t1 = _context.sent;
(0, _context.t0)(_context.t1).toHaveNoViolations();
case 5:
case 'end':
return _context.stop();
}
}
}, _callee, undefined);
})));
it('renders an unordered list by default', function () {
expect(render().type()).toBe('ul');
});
describe('with ordered prop', function () {
beforeEach(function () {
props.ordered = true;
});
it('renders correctly', function () {
expect(render()).toMatchSnapshot();
});
it('renders an ordered list', function () {
expect(render().type()).toBe('ol');
});
});
describe('with flush set', function () {
beforeEach(function () {
props.flush = true;
});
it('renders correctly', function () {
expect(render()).toMatchSnapshot();
});
});
describe('with columns set', function () {
beforeEach(function () {
props.columns = 3;
});
it('renders correctly', function () {
expect(render()).toMatchSnapshot();
});
});
describe('with responsive columns set', function () {
beforeEach(function () {
props.columns = [1, 2, 3];
});
it('renders correctly', function () {
expect(render()).toMatchSnapshot();
});
});
});
;