@roo-ui/components
Version:
83 lines (72 loc) • 3.21 kB
JavaScript
var _react = _interopRequireDefault(require("react"));
var _themes = require("@roo-ui/themes");
var _testUtils = require("@roo-ui/test-utils");
var _jestAxe = require("jest-axe");
var _ = _interopRequireDefault(require("."));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
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); }); }; }
describe('<PasswordInput />', function () {
var wrapper;
beforeEach(function () {
wrapper = (0, _testUtils.mountWithTheme)(_react.default.createElement(_.default, null), _themes.qantas);
});
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:
wrapper = (0, _testUtils.mountWithTheme)(_react.default.createElement("label", {
htmlFor: "input"
}, "Label", _react.default.createElement(_.default, {
id: "input"
})), _themes.qantas);
_context.t0 = expect;
_context.next = 4;
return (0, _jestAxe.axe)(wrapper.html());
case 4:
_context.t1 = _context.sent;
(0, _context.t0)(_context.t1).toHaveNoViolations();
case 6:
case "end":
return _context.stop();
}
}
}, _callee);
})));
describe('when visibility is not toggled', function () {
it('renders correctly', function () {
expect(wrapper).toMatchSnapshot();
});
describe('on visibility toggle click', function () {
beforeEach(function () {
wrapper.find('PasswordInput__Toggle').simulate('click');
wrapper.update();
});
it('sets <input /> type to text', function () {
expect(wrapper.find('PasswordInput__Input').props()).toHaveProperty('type', 'text');
});
});
});
describe('when visibility is toggled', function () {
beforeEach(function () {
wrapper.find('PasswordInput__Toggle').simulate('click');
});
it('renders correctly', function () {
expect(wrapper).toMatchSnapshot();
});
describe('on visibility toggle click', function () {
beforeEach(function () {
wrapper.find('PasswordInput__Toggle').simulate('click');
});
it('sets <input /> type to password', function () {
expect(wrapper.update().find('PasswordInput__Input').props()).toHaveProperty('type', 'password');
});
});
});
});
;