UNPKG

@roo-ui/components

Version:

91 lines (84 loc) 3.17 kB
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } } function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; } import React from 'react'; import { axe } from 'jest-axe'; import { qantas as theme } from '@roo-ui/themes'; import { mountWithTheme } from '@roo-ui/test-utils'; import { List, ListItem } from '..'; describe('<List />', function () { var props; beforeEach(function () { props = {}; }); var tree = function tree() { return React.createElement(List, props, React.createElement(ListItem, null, "Hello Item 1"), React.createElement(ListItem, null, "Hello Item 2"), React.createElement(ListItem, null, "Hello Item 3")); }; var render = function render() { return mountWithTheme(tree(), theme); }; it('renders correctly', function () { expect(render()).toMatchSnapshot(); }); it('has no accessibility errors', /*#__PURE__*/ _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 axe(render().html()); case 3: _context.t1 = _context.sent; (0, _context.t0)(_context.t1).toHaveNoViolations(); case 5: case "end": return _context.stop(); } } }, _callee); }))); it('renders an unordered list by default', function () { expect(render().find('ul')).toHaveLength(1); expect(render().find('ol')).toHaveLength(0); }); 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().find('ol')).toHaveLength(1); expect(render().find('ul')).toHaveLength(0); }); }); 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(); }); }); });