UNPKG

@roo-ui/components

Version:

108 lines (100 loc) 4.41 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); }); }; } function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } import React from 'react'; import { qantas as theme } from '@roo-ui/themes'; import { shallowWithTheme } from '@roo-ui/test-utils'; import { axe } from 'jest-axe'; import Hide from '.'; describe('<Hide />', function () { var wrapper; var testWithBreakpoints = function testWithBreakpoints(breakpoints) { describe('no props', function () { beforeEach(function () { wrapper = shallowWithTheme(React.createElement(Hide, null, "Hello world"), _objectSpread({}, theme, { breakpoints: breakpoints })); }); it('renders correctly', function () { expect(wrapper).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(wrapper.html()); case 3: _context.t1 = _context.sent; (0, _context.t0)(_context.t1).toHaveNoViolations(); case 5: case "end": return _context.stop(); } } }, _callee); }))); }); describe('xs', function () { beforeEach(function () { wrapper = shallowWithTheme(React.createElement(Hide, { xs: true }, "Hello world"), _objectSpread({}, theme, { breakpoints: breakpoints })); }); it('renders correctly', function () { expect(wrapper).toMatchSnapshot(); }); }); describe('sm', function () { beforeEach(function () { wrapper = shallowWithTheme(React.createElement(Hide, { sm: true }, "Hello world"), _objectSpread({}, theme, { breakpoints: breakpoints })); }); it('renders correctly', function () { expect(wrapper).toMatchSnapshot(); }); }); describe('md', function () { beforeEach(function () { wrapper = shallowWithTheme(React.createElement(Hide, { md: true }, "Hello world"), _objectSpread({}, theme, { breakpoints: breakpoints })); }); it('renders correctly', function () { expect(wrapper).toMatchSnapshot(); }); }); describe('lg', function () { beforeEach(function () { wrapper = shallowWithTheme(React.createElement(Hide, { lg: true }, "Hello world"), _objectSpread({}, theme, { breakpoints: breakpoints })); }); it('renders correctly', function () { expect(wrapper).toMatchSnapshot(); }); }); }; describe('with breakpoints in rems', function () { testWithBreakpoints(['40rem', '52rem', '64rem']); }); describe('with breakpoints in px', function () { testWithBreakpoints(['768px', '1100px', '1280px']); }); });