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 3.2.2 to 3.3.0

2

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

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

@@ -6,3 +6,3 @@ const css = require('css')

const getClassName = (received) => {
const getClassNames = (received) => {
let className = ''

@@ -16,12 +16,20 @@

return `.${className.split(/\s/).pop()}`
return className.split(/\s/)
}
const getRules = (ast, className) => ast.stylesheet.rules.filter(
rule => rule.type === 'rule' && rule.selectors.includes(className)
const hasRule = (classNames, selectors) => classNames.some(
className => selectors.includes(`.${className}`)
)
const getDeclarations = (rule, property) => rule.declarations.filter(
const getRules = (ast, classNames) => ast.stylesheet.rules.filter(
rule => rule.type === 'rule' && hasRule(classNames, rule.selectors)
)
const getDeclaration = (rule, property) => rule.declarations.filter(
declaration => declaration.type === 'declaration' &&
declaration.property === property
)[0]
const getDeclarations = (rules, property) => rules.map(
rule => getDeclaration(rule, property)
)

@@ -34,7 +42,7 @@

function toHaveStyleRule(received, property, value) {
const className = getClassName(received)
const toHaveStyleRule = (received, property, value) => {
const classNames = getClassNames(received)
const styles = getCSS(styleSheet)
const ast = css.parse(styles)
const rules = getRules(ast, className)
const rules = getRules(ast, classNames)

@@ -45,3 +53,3 @@ if (!rules.length) {

const declarations = getDeclarations(rules[0], property)
const declarations = getDeclarations(rules, property)

@@ -52,3 +60,3 @@ if (!declarations.length) {

const declaration = declarations[0]
const declaration = declarations.pop()

@@ -55,0 +63,0 @@ const message =

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