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 6.2.2 to 7.0.0-0

5

CHANGELOG.md

@@ -7,7 +7,2 @@ # Changelog

## [6.2.1](https://github.com/styled-components/jest-styled-components/compare/v6.2.0...v6.2.1) - 2018-09-22
### Fixed
- [toHaveStyleRule] Do not fail when components have empty string as children (see [#189](https://github.com/styled-components/jest-styled-components/pull/189)).
## [6.2.0](https://github.com/styled-components/jest-styled-components/compare/v6.1.1...v6.2.0) - 2018-09-08

@@ -14,0 +9,0 @@ ### Added

4

package.json
{
"name": "jest-styled-components",
"version": "6.2.2",
"version": "7.0.0-0",
"description": "Jest utilities for Styled Components",

@@ -54,3 +54,3 @@ "main": "./src/index.js",

"react-testing-library": "^5.0.1",
"styled-components": "^3.4.5",
"styled-components": "^4.0.0-beta.1",
"typescript": "^3.0.3"

@@ -57,0 +57,0 @@ },

@@ -47,3 +47,2 @@ [![NPM version](https://img.shields.io/npm/v/jest-styled-components.svg)](https://www.npmjs.com/package/jest-styled-components)

* [Preact](#preact)
* [Serializer](#serializer)
* [toHaveStyleRule](#tohavestylerule)

@@ -324,26 +323,2 @@ * [Global installation](#global-installation)

## Serializer
The serializer can be imported separately from `jest-styled-components/serializer`.
This makes it possible to use this package with [specific-snapshot](https://github.com/igor-dv/jest-specific-snapshot) and other libraries.
```js
import React from 'react'
import styled from 'styled-components'
import renderer from 'react-test-renderer'
import { styleSheetSerializer } from "jest-styled-components/serializer"
import { addSerializer } from "jest-specific-snapshot"
addSerializer(styleSheetSerializer)
const Button = styled.button`
color: red;
`
test('it works', () => {
const tree = renderer.create(<Button />).toJSON()
expect(tree).toMatchSpecificSnapshot("./Button.snap")
})
````
# toHaveStyleRule

@@ -350,0 +325,0 @@

@@ -0,9 +1,7 @@

import { __DO_NOT_USE_OR_YOU_WILL_BE_HAUNTED_BY_SPOOKY_GHOSTS as internals } from 'styled-components'
const { getCSS, matcherTest, buildReturnMessage } = require('./utils')
const shouldDive = node =>
typeof node.dive === 'function' && typeof node.type() !== 'string'
const { StyleSheet } = internals
const isTagWithClassName = node =>
node.exists() && node.prop('className') && typeof node.type() === 'string'
const getClassNames = received => {

@@ -16,6 +14,16 @@ let className

} else if (typeof received.exists === 'function' && received.exists()) {
const tree = shouldDive(received) ? received.dive() : received
const components = tree.findWhere(isTagWithClassName)
if (components.length) {
className = components.first().prop('className')
const base = received.find('BaseStyledComponent')
if (base.length) {
if (received.dive) {
className = base
.dive()
.props()
.children(StyleSheet.master)
.props.children().props.className
} else {
className = base
.children()
.first()
.prop('className')
}
}

@@ -105,9 +113,8 @@ } else if (global.Element && received instanceof global.Element) {

const normalizeOptions = (options) =>
options.modifier
? Object.assign(
{},
options,
{ modifier: Array.isArray(options.modifier) ? options.modifier.join('') : options.modifier },
)
const normalizeOptions = ({ modifier, ...options }) =>
modifier
? {
...options,
modifier: Array.isArray(modifier) ? modifier.join('') : modifier,
}
: options

@@ -114,0 +121,0 @@

@@ -6,3 +6,3 @@ interface AsymmetricMatcher {

type Value = string | number | RegExp | AsymmetricMatcher | undefined
type Value = string | RegExp | AsymmetricMatcher | undefined

@@ -9,0 +9,0 @@ interface Options {

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