@hashicorp/react-vertical-text-block-list
Advanced tools
Comparing version 2.0.1 to 2.0.2
@@ -32,23 +32,23 @@ 'use strict'; | ||
Link = _ref.Link; | ||
return React.createElement("div", { | ||
return /*#__PURE__*/React.createElement("div", { | ||
className: "g-vertical-text-block-list", | ||
"data-testid": "root" | ||
}, React.createElement("ul", { | ||
}, /*#__PURE__*/React.createElement("ul", { | ||
className: "list".concat(centerText ? ' centered-text' : ''), | ||
"data-testid": "item-list" | ||
}, data.map(function (item) { | ||
return React.createElement("li", { | ||
return /*#__PURE__*/React.createElement("li", { | ||
key: item.body | ||
}, React.createElement(MaybeLink, { | ||
}, /*#__PURE__*/React.createElement(MaybeLink, { | ||
link: item.linkUrl, | ||
LinkComponent: Link | ||
}, React.createElement("div", { | ||
}, /*#__PURE__*/React.createElement("div", { | ||
className: "header", | ||
"data-testid": "header-".concat(item.header) | ||
}, item.logo ? React.createElement(Image, _extends({}, item.logo, { | ||
}, item.logo ? /*#__PURE__*/React.createElement(Image, _extends({}, item.logo, { | ||
"data-testid": "img" | ||
})) : React.createElement("h6", { | ||
})) : /*#__PURE__*/React.createElement("h6", { | ||
className: "g-type-display-4", | ||
"data-testid": "text" | ||
}, item.header)), React.createElement("div", { | ||
}, item.header)), /*#__PURE__*/React.createElement("div", { | ||
className: "body-text g-type-body-large", | ||
@@ -67,3 +67,3 @@ dangerouslySetInnerHTML: { | ||
children = _ref2.children; | ||
return link ? React.createElement(LinkWrap, { | ||
return link ? /*#__PURE__*/React.createElement(LinkWrap, { | ||
Link: LinkComponent, | ||
@@ -73,3 +73,3 @@ href: link, | ||
"data-testid": "link" | ||
}, children) : React.createElement("div", { | ||
}, children) : /*#__PURE__*/React.createElement("div", { | ||
className: "wrapper", | ||
@@ -76,0 +76,0 @@ "data-testid": "div" |
import React from 'react' | ||
import { render, cleanup } from '@testing-library/react' | ||
import { render, screen } from '@testing-library/react' | ||
import '@testing-library/jest-dom/extend-expect' | ||
@@ -8,17 +8,19 @@ import VerticalTextBlockList from './dist/index' | ||
const defaultProps = global.propSpecToObj(propsSpec.default) | ||
afterEach(cleanup) | ||
describe('<VerticalTextBlockList />', () => { | ||
it('should render correctly with default props', () => { | ||
const { getByTestId } = render(<VerticalTextBlockList {...defaultProps} />) | ||
expect(getByTestId('root').className).toBe('g-vertical-text-block-list') | ||
render(<VerticalTextBlockList {...defaultProps} />) | ||
expect(screen.getByTestId('root').className).toBe( | ||
'g-vertical-text-block-list' | ||
) | ||
// all items in the data list render | ||
expect(getByTestId('item-list').children.length).toBe( | ||
expect(screen.getByTestId('item-list').children.length).toBe( | ||
defaultProps.data.length | ||
) | ||
defaultProps.data.map(item => { | ||
defaultProps.data.map((item) => { | ||
// item.logo presence/absense changes render | ||
const headerFirstChild = getByTestId(`header-${item.header}`).children[0] | ||
const headerFirstChild = screen.getByTestId(`header-${item.header}`) | ||
.children[0] | ||
if (item.logo) { | ||
@@ -33,7 +35,7 @@ expect(headerFirstChild).toHaveAttribute('data-testid', 'img') | ||
it('should render body text as markdown', () => { | ||
const { getByTestId } = render( | ||
render( | ||
<VerticalTextBlockList data={[{ header: 'test', body: '**foo**' }]} /> | ||
) | ||
expect( | ||
getByTestId(`body-text-test`).querySelector('strong') | ||
screen.getByTestId(`body-text-test`).querySelector('strong') | ||
).toBeInTheDocument() | ||
@@ -43,13 +45,9 @@ }) | ||
it('should have a class with the "centerText" prop active', () => { | ||
const { getByTestId } = render( | ||
<VerticalTextBlockList {...defaultProps} centerText={true} /> | ||
) | ||
expect(getByTestId('item-list')).toHaveClass('centered-text') | ||
render(<VerticalTextBlockList {...defaultProps} centerText={true} />) | ||
expect(screen.getByTestId('item-list')).toHaveClass('centered-text') | ||
}) | ||
it('should render links correctly when a "Link" prop is passed', () => { | ||
const { getByTestId } = render( | ||
<VerticalTextBlockList {...defaultProps} Link={noopComponent} /> | ||
) | ||
Array.from(getByTestId('item-list').children).map((child, i) => { | ||
render(<VerticalTextBlockList {...defaultProps} Link={noopComponent} />) | ||
Array.from(screen.getByTestId('item-list').children).map((child, i) => { | ||
const hasLink = defaultProps.data[i].linkUrl | ||
@@ -56,0 +54,0 @@ if (hasLink) { |
{ | ||
"name": "@hashicorp/react-vertical-text-block-list", | ||
"description": "Vertical block list of links", | ||
"version": "2.0.1", | ||
"version": "2.0.2", | ||
"author": "Hashicorp - Mike Wickett", | ||
"dependencies": { | ||
"@hashicorp/react-image": "^2.0.1", | ||
"@hashicorp/react-image": "^2.0.2", | ||
"@hashicorp/react-link-wrap": "^0.0.3", | ||
@@ -22,3 +22,3 @@ "marked": "^0.7.0" | ||
}, | ||
"gitHead": "661e01731e31241b9b32862dad4eb376cabefe2a" | ||
"gitHead": "91411752de6f18e074f8492cc7690f1b05961527" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
31340
425
1