ansi-to-react
Advanced tools
Comparing version 1.3.0 to 1.4.0
@@ -71,7 +71,8 @@ 'use strict'; | ||
function Ansi(props) { | ||
return React.createElement('code', {}, props.linkify ? ansiToInlineStyle(props.children).map(linkifyBundle).map(inlineBundleToReact) : ansiToInlineStyle(props.children).map(inlineBundleToReact)); | ||
return React.createElement('code', { className: props.className }, props.linkify ? ansiToInlineStyle(props.children).map(linkifyBundle).map(inlineBundleToReact) : ansiToInlineStyle(props.children).map(inlineBundleToReact)); | ||
} | ||
Ansi.propTypes = { | ||
children: PropTypes.string | ||
children: PropTypes.string, | ||
className: PropTypes.string | ||
}; | ||
@@ -78,0 +79,0 @@ |
{ | ||
"name": "ansi-to-react", | ||
"version": "1.3.0", | ||
"version": "1.4.0", | ||
"description": "ANSI to React Elements", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -74,3 +74,3 @@ const React = require('react'); | ||
'code', | ||
{}, | ||
{className: props.className}, | ||
props.linkify | ||
@@ -86,4 +86,5 @@ ? ansiToInlineStyle(props.children) | ||
children: PropTypes.string, | ||
className: PropTypes.string | ||
}; | ||
module.exports = Ansi; |
@@ -24,2 +24,9 @@ const Ansi = require('../src/index'); | ||
it('can have className', () => { | ||
const el = enzyme.shallow(React.createElement(Ansi, {className: 'my-class'}, `hello world`)); | ||
expect(el).to.not.be.null; | ||
expect(el.text()).to.equal('hello world'); | ||
expect(el.html()).to.equal('<code class="my-class"><span>hello world</span></code>'); | ||
}); | ||
it('can nest', () => { | ||
@@ -37,3 +44,3 @@ const el = enzyme.shallow(React.createElement(Ansi, null, `hello ${GREEN_FG}wo${YELLOW_BG}rl${RESET}d`)); | ||
}); | ||
it('can linkify', () => { | ||
@@ -45,3 +52,3 @@ const el = enzyme.shallow(React.createElement(Ansi, {linkify: true}, 'this is a link: https://nteract.io/')); | ||
}); | ||
it('can distinguish URL-ish text', () => { | ||
@@ -52,3 +59,3 @@ const el = enzyme.shallow(React.createElement(Ansi, {linkify: true}, '<transport.model.TransportInfo')); | ||
}); | ||
it('can distinguish URL-ish text', () => { | ||
@@ -55,0 +62,0 @@ const el = enzyme.shallow(React.createElement(Ansi, {linkify: true}, "<module 'something' from '/usr/local/lib/python2.7/dist-packages/something/__init__.pyc'>")); |
Sorry, the diff of this file is not supported yet
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
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
13842
201