@brightleaf/elements
Version:
React UI elements styled with Bulma CSS
69 lines (56 loc) • 2.3 kB
JavaScript
;
var _react = _interopRequireDefault(require("react"));
var _react2 = require("@testing-library/react");
var _jestDom = require("@testing-library/jest-dom");
var _ = require("../");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
expect.extend({
toHaveClass: _jestDom.toHaveClass,
toHaveAttribute: _jestDom.toHaveAttribute
});
describe('ConfirmButton componentu', function () {
afterEach(_react2.cleanup);
it('should render', function () {
var _render = (0, _react2.render)(_react.default.createElement(_.ConfirmButton, null, "Button")),
container = _render.container;
expect(container).toMatchSnapshot();
expect(container.firstChild).toHaveClass('button');
});
it('should render a button', function () {
var _render2 = (0, _react2.render)(_react.default.createElement(_.ConfirmButton, {
title: "confirm",
question: "Are you sure you want to send the message?",
onConfirm: function onConfirm(e) {},
onCancel: function onCancel() {}
}, "Send")),
container = _render2.container;
expect(container).toMatchSnapshot();
expect(container.firstChild).toHaveClass('button');
expect(container.lastChild.firstChild).toHaveClass('modal');
});
it('should when the button is clicked add `is-active` class to modal', function _callee() {
var _render3, container, modal;
return regeneratorRuntime.async(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
_render3 = (0, _react2.render)(_react.default.createElement(_.ConfirmButton, {
title: "confirm",
question: "Are you sure you want to send the message?",
onConfirm: function onConfirm(e) {},
onCancel: function onCancel() {}
}, "Send")), container = _render3.container;
_react2.fireEvent.click(container.firstChild);
_context.next = 4;
return regeneratorRuntime.awrap(container.lastChild.firstChild);
case 4:
modal = _context.sent;
expect(modal).toHaveClass('is-active');
case 6:
case "end":
return _context.stop();
}
}
});
});
});