jest-styled-components
Advanced tools
Comparing version 4.1.0-1 to 4.1.0-2
{ | ||
"name": "jest-styled-components", | ||
"version": "4.1.0-1", | ||
"version": "4.1.0-2", | ||
"description": "Jest utilities for Styled Components", | ||
@@ -5,0 +5,0 @@ "main": "./src/index.js", |
@@ -67,15 +67,11 @@ const css = require('css') | ||
const replaceHashes = (classNames, hashes, result) => | ||
classNames | ||
.filter( | ||
className => className.startsWith('sc-') || hashes.includes(className) | ||
) | ||
.reduce( | ||
(acc, className) => | ||
acc.replace( | ||
new RegExp(`(className="[^"]*?)${className}\\s?([^"]*")`, 'g'), | ||
'$1$2' | ||
), | ||
result | ||
) | ||
const replaceHashes = (hashes, result) => | ||
hashes.reduce( | ||
(acc, className) => | ||
acc.replace( | ||
new RegExp(`(className="[^"]*?)${className}\\s?([^"]*")`, 'g'), | ||
'$1$2' | ||
), | ||
result | ||
) | ||
@@ -99,3 +95,3 @@ const styleSheetSerializer = { | ||
result = replaceClassNames(classNames, style, result) | ||
result = replaceHashes(classNames, hashes, result) | ||
result = replaceHashes(hashes, result) | ||
@@ -102,0 +98,0 @@ return result |
@@ -41,7 +41,10 @@ const css = require('css') | ||
const getClassNames = () => extract(/data-styled-components="([^"]*)"/g) | ||
const getClassNames = () => | ||
extract(/data-styled-components="([^"]*)"/g).split(/\s/) | ||
const getComponentIDs = () => extract(/sc-component-id: ([^\\*\\/]*) \*\//g) | ||
const getComponentIDs = () => | ||
extract(/sc-component-id: ([^\\*\\/]*) \*\//g).split(/\s/) | ||
const getHashes = () => `${getClassNames()} ${getComponentIDs()}` | ||
const getHashes = () => | ||
getClassNames().concat(getComponentIDs()).filter(Boolean) | ||
@@ -48,0 +51,0 @@ module.exports = { |
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
17216
281