jest-styled-components
Advanced tools
Comparing version 4.0.2 to 4.0.3
{ | ||
"name": "jest-styled-components", | ||
"version": "4.0.2", | ||
"version": "4.0.3", | ||
"description": "Jest utilities for Styled Components", | ||
@@ -5,0 +5,0 @@ "main": "./src/index.js", |
@@ -5,3 +5,3 @@ const css = require('css') | ||
const getClassNames = node => { | ||
const classNames = [] | ||
let classNames = new Set() | ||
@@ -12,4 +12,5 @@ if (node.children) { | ||
.reverse() | ||
.forEach(child => | ||
Array.prototype.unshift.apply(classNames, getClassNames(child)) | ||
.forEach( | ||
child => | ||
(classNames = new Set([...getClassNames(child), ...classNames])) | ||
) | ||
@@ -19,3 +20,3 @@ } | ||
if (node.props && node.props.className) { | ||
Array.prototype.unshift.apply(classNames, node.props.className.split(/\s/)) | ||
classNames = new Set([...node.props.className.split(/\s/), ...classNames]) | ||
} | ||
@@ -84,3 +85,3 @@ | ||
const classNames = getClassNames(val) | ||
const classNames = [...getClassNames(val)] | ||
const style = getStyle(classNames) | ||
@@ -87,0 +88,0 @@ const code = print(val) |
@@ -5,11 +5,13 @@ const { printReceived, printExpected } = require('jest-matcher-utils') | ||
const getClassNames = received => { | ||
let className = '' | ||
let className | ||
if (received.$$typeof === Symbol.for('react.test.json')) { | ||
className = received.props.className | ||
} else if (typeof received.find === 'function') { | ||
className = received.find('[className]').first().prop('className') | ||
if (received) { | ||
if (received.$$typeof === Symbol.for('react.test.json')) { | ||
className = received.props.className | ||
} else if (typeof received.find === 'function') { | ||
className = received.find('[className]').first().prop('className') | ||
} | ||
} | ||
return className.split(/\s/) | ||
return className ? className.split(/\s/) : [] | ||
} | ||
@@ -16,0 +18,0 @@ |
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
16790
269