@brightleaf/elements
Version:
React UI elements styled with Bulma CSS
121 lines (102 loc) • 4.49 kB
JavaScript
;
var _react = _interopRequireDefault(require("react"));
var _react2 = require("@testing-library/react");
var _jestDom = require("@testing-library/jest-dom");
var _index = require("../index");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
expect.extend({
toBeInTheDocument: _jestDom.toBeInTheDocument,
toHaveClass: _jestDom.toHaveClass
});
describe('Column and Columns', function () {
afterEach(_react2.cleanup);
it('should render', function () {
var _render = (0, _react2.render)(_react.default.createElement(_index.Notification, null, _react.default.createElement("div", null, "Hi"))),
container = _render.container;
expect(container.firstChild).toMatchSnapshot();
});
it('should render isInfo with class is-info', function () {
var _render2 = (0, _react2.render)(_react.default.createElement(_index.Notification, {
isInfo: true
}, _react.default.createElement("div", null, "Hi"))),
container = _render2.container;
expect(container.firstChild).toMatchSnapshot();
expect(container.firstChild).toHaveClass('is-info');
});
/*
isMobile,
className,
isFluid,
isWideScreen,
isFullHD,
*/
it('should render isSuccess with class is-success', function () {
var _render3 = (0, _react2.render)(_react.default.createElement(_index.Notification, {
isSuccess: true
}, _react.default.createElement("div", null, "Hi"))),
container = _render3.container;
expect(container.firstChild).toMatchSnapshot();
expect(container.firstChild).toHaveClass('is-success');
});
it('should render isDanger with class is-danger', function () {
var _render4 = (0, _react2.render)(_react.default.createElement(_index.Notification, {
isDanger: true
}, _react.default.createElement("div", null, "Hi"))),
container = _render4.container;
expect(container.firstChild).toMatchSnapshot();
expect(container.firstChild).toHaveClass('is-danger');
});
it('should render isPrimary with class is-primary', function () {
var _render5 = (0, _react2.render)(_react.default.createElement(_index.Notification, {
isPrimary: true
}, _react.default.createElement("div", null, "Hi"))),
container = _render5.container;
expect(container.firstChild).toMatchSnapshot();
expect(container.firstChild).toHaveClass('is-primary');
});
it('should render isLink with class is-link', function () {
var _render6 = (0, _react2.render)(_react.default.createElement(_index.Notification, {
isLink: true
}, _react.default.createElement("div", null, "Hi"))),
container = _render6.container;
expect(container.firstChild).toMatchSnapshot();
expect(container.firstChild).toHaveClass('is-link');
});
it('should render isWarning with class is-warning', function () {
var _render7 = (0, _react2.render)(_react.default.createElement(_index.Notification, {
isWarning: true
}, _react.default.createElement("div", null, "Hi"))),
container = _render7.container;
expect(container.firstChild).toMatchSnapshot();
expect(container.firstChild).toHaveClass('is-warning');
});
it('should not render with when isShow is false', function _callee() {
var mockDismiss, _render8, container, getByTitle, notificationNode;
return regeneratorRuntime.async(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
mockDismiss = jest.fn(function () {});
_render8 = (0, _react2.render)(_react.default.createElement(_index.Notification, {
isShown: true,
isPrimary: true,
onDismiss: mockDismiss
}, _react.default.createElement("div", null, "Hi"))), container = _render8.container, getByTitle = _render8.getByTitle;
expect(container.firstChild).toMatchSnapshot();
_react2.fireEvent.click(getByTitle(/dismiss notification/i));
_context.next = 6;
return regeneratorRuntime.awrap((0, _react2.waitForElement)(function () {
return getByTitle('notification element');
}));
case 6:
notificationNode = _context.sent;
expect(notificationNode).toMatchSnapshot();
expect(mockDismiss).toHaveBeenCalled();
case 9:
case "end":
return _context.stop();
}
}
});
});
});