@bootstrap-styled/v4
Version:
twbs/bootstrap V4 UI Components made with bootstrap-styled. Work with css-in-js, react, styled-components, and Bootstrap Styled utilities.
140 lines (131 loc) • 5.25 kB
JavaScript
"use strict";
var _react = _interopRequireDefault(require("react"));
var _enzyme = require("enzyme");
var _BootstrapProvider = _interopRequireDefault(require("@bootstrap-styled/provider/lib/BootstrapProvider"));
var _index = _interopRequireDefault(require("../index"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
* Testing our link component
*/
var children = _react.default.createElement("h1", null, "Test");
var renderComponent = function renderComponent() {
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
return (0, _enzyme.mount)(_react.default.createElement(_index.default, props, children));
};
var renderComponentUsingTheme = function renderComponentUsingTheme() {
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
return (0, _enzyme.mount)(_react.default.createElement(_BootstrapProvider.default, null, _react.default.createElement(_index.default, props, children)));
};
describe('<A />', function () {
it('should render an <A> tag without a theme', function () {
var renderedComponent = renderComponent({
href: 'https://bootstrap-styled.kopaxgroup.com/',
children: children,
type: 'text/html',
target: '_blank'
});
expect(renderedComponent.find('AUnstyled').length).toBe(1);
});
it('should have an href attribute without a theme', function () {
var renderedComponent = renderComponent({
href: 'https://bootstrap-styled.kopaxgroup.com/',
children: children
});
expect(renderedComponent.props().href).toEqual('https://bootstrap-styled.kopaxgroup.com/');
});
it('should adopt a target attribute without a theme', function () {
var renderedComponent = renderComponent({
target: '_blank',
href: 'https://bootstrap-styled.kopaxgroup.com/',
children: children
});
expect(renderedComponent.props().target).toEqual('_blank');
});
it('should adopt a type attribute without a theme', function () {
var renderedComponent = renderComponent({
type: 'text/html',
href: 'https://bootstrap-styled.kopaxgroup.com/',
children: children
});
expect(renderedComponent.props().type).toEqual('text/html');
});
it('should have children without a theme', function () {
var renderedComponent = renderComponent({
target: '_blank',
href: 'https://bootstrap-styled.kopaxgroup.com/',
children: children
});
expect(renderedComponent.contains(children)).toEqual(true);
});
it('should render an <a> tag with a theme', function () {
var renderedComponent = renderComponentUsingTheme({
target: '_blank',
href: 'https://bootstrap-styled.kopaxgroup.com/',
children: children
});
expect(renderedComponent.find('a').length).toBe(1);
expect(renderedComponent.find('A').length).toBe(1);
});
it('should render a href attribute of <A> with a theme', function () {
var renderedComponent = renderComponentUsingTheme({
href: 'https://bootstrap-styled.kopaxgroup.com/',
children: children,
type: 'text/html',
target: '_blank'
});
expect(renderedComponent.find('a').props().href).toEqual('https://bootstrap-styled.kopaxgroup.com/');
});
it('should render an type attribute of <A> with a theme', function () {
var renderedComponent = renderComponentUsingTheme({
href: 'https://bootstrap-styled.kopaxgroup.com/',
children: children,
type: 'text/html',
target: '_blank'
});
expect(renderedComponent.find('a').props().type).toEqual('text/html');
});
it('should render a target attribute of <A> with a theme', function () {
var renderedComponent = renderComponentUsingTheme({
href: 'https://bootstrap-styled.kopaxgroup.com/',
children: children,
type: 'text/html',
target: '_blank'
});
expect(renderedComponent.find('a').props().target).toEqual('_blank');
});
it('should have an attribute color', function () {
var renderedComponent = renderComponentUsingTheme({
href: 'https://bootstrap-styled.kopaxgroup.com/',
children: children,
color: 'white'
});
expect(renderedComponent.find('a').hasClass('text-white')).toBe(true);
});
it('should have children with a theme', function () {
var renderedComponent = renderComponentUsingTheme({
target: '_blank',
href: 'https://bootstrap-styled.kopaxgroup.com/',
children: children
});
expect(renderedComponent.contains(children)).toEqual(true);
});
it('className should set a class', function () {
var renderedComponent = renderComponentUsingTheme({
className: 'btn',
target: '_blank',
href: 'https://bootstrap-styled.kopaxgroup.com/',
children: children
});
expect(renderedComponent.find('a').hasClass('btn')).toBe(true);
});
it('color should set a class', function () {
var renderedComponent = renderComponentUsingTheme({
className: 'btn',
target: '_blank',
href: 'https://bootstrap-styled.kopaxgroup.com/',
children: children,
color: 'primary'
});
expect(renderedComponent.find('a').hasClass('text-primary')).toBe(true);
});
});