Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

jest-styled-components

Package Overview
Dependencies
Maintainers
2
Versions
104
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jest-styled-components - npm Package Compare versions

Comparing version 1.1.1 to 1.2.0

2

package.json
{
"name": "jest-styled-components",
"version": "1.1.1",
"version": "1.2.0",
"description": "Jest utilities for Styled Components",

@@ -5,0 +5,0 @@ "main": "./src/index.js",

@@ -20,8 +20,11 @@ const chalk = require('chalk')

}
if (isAddition(line)) {
return chalk.green(line)
}
if (isDeletion(line)) {
return chalk.red(line)
}
return chalk.gray(line)

@@ -28,0 +31,0 @@ }).join('\n')

@@ -10,15 +10,37 @@ const css = require('css')

}
if (node.props && node.props.className) {
return classNames.concat(node.props.className.split(' '))
}
return []
}
const filterNodes = classNames => rule => (
rule.type === 'rule' && classNames.includes(rule.selectors[0].substring(1))
)
const getMediaQueries = (ast, filter) => (
ast.stylesheet.rules
.filter(rule => rule.type === 'media')
.reduce((acc, mediaQuery) => {
mediaQuery.rules = mediaQuery.rules.filter(filter)
if (mediaQuery.rules.length) {
return acc.concat(mediaQuery)
}
return acc
}, [])
)
const getStyles = (classNames) => {
const styles = styleSheet.rules().map(rule => rule.cssText).join('\n')
const ast = css.parse(styles)
ast.stylesheet.rules = ast.stylesheet.rules.filter(rule => (
rule.type === 'rule' && classNames.includes(rule.selectors[0].substring(1))
))
const filter = filterNodes(classNames)
const rules = ast.stylesheet.rules.filter(filter)
const mediaQueries = getMediaQueries(ast, filter)
ast.stylesheet.rules = rules.concat(mediaQueries)
return css.stringify(ast)

@@ -36,2 +58,3 @@ }

const styles = getStyles(classNames)
val.withStyles = true

@@ -38,0 +61,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc