Security News
New Python Packaging Proposal Aims to Solve Phantom Dependency Problem with SBOMs
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
enzyme-redux
Advanced tools
Test utils to simplify testing of containers in redux with enzyme.
In the terminal execute the following command:
$ npm install enzyme-redux --save-dev
import React from 'react';
import { connect } from 'react-redux';
import { shallowWithStore } from 'enzyme-redux';
import { createMockStore } from 'redux-test-utils';
describe('example shallowWithStore', () => {
const ReactComponent = () => (<div>dummy component</div>);
describe('state', () => {
it('works', () => {
const expectedState = 'expectedState';
const mapStateToProps = (state) => ({
state,
});
const ConnectedComponent = connect(mapStateToProps)(ReactComponent);
const component = shallowWithStore(<ConnectedComponent />, createMockStore(expectedState));
expect(component.props().state).toBe(expectedState);
});
});
describe('dispatch', () => {
it('works', () => {
const action = {
type: 'type',
};
const mapDispatchToProps = (dispatch) => ({
dispatchProp() {
dispatch(action);
},
});
const store = createMockStore();
const ConnectedComponent = connect(undefined, mapDispatchToProps)(ReactComponent);
const component = shallowWithStore(<ConnectedComponent />, store);
component.props().dispatchProp();
expect(store.isActionDispatched(action)).toBe(true);
});
});
});
import React from 'react';
import { connect } from 'react-redux';
import { shallowWithState } from 'enzyme-redux';
describe('example shallowWithState', () => {
const ReactComponent = () => (<div>dummy component</div>);
it('works', () => {
const expectedState = 'expectedState';
const mapStateToProps = (state) => ({
state,
});
const ConnectedComponent = connect(mapStateToProps)(ReactComponent);
const component = shallowWithState(<ConnectedComponent />, expectedState);
expect(component.props().state).toBe(expectedState);
});
});
import React from 'react';
import { connect } from 'react-redux';
import { mountWithStore } from 'enzyme-redux';
import { createMockStore } from 'redux-test-utils';
describe('example mountWithStore', () => {
const ReactComponent = () => (<div>dummy component</div>);
describe('state', () => {
it('works', () => {
const expectedState = 'expectedState';
const mapStateToProps = (state) => ({
state,
});
const ConnectedComponent = connect(mapStateToProps)(ReactComponent);
const component = mountWithStore(<ConnectedComponent />, createMockStore(expectedState));
expect(component.props().state).toBe(expectedState);
});
});
describe('dispatch', () => {
it('works', () => {
const action = {
type: 'type',
};
const mapDispatchToProps = (dispatch) => ({
dispatchProp() {
dispatch(action);
},
});
const store = createMockStore();
const ConnectedComponent = connect(undefined, mapDispatchToProps)(ReactComponent);
const component = mountWithStore(<ConnectedComponent />, store);
component.props().dispatchProp();
expect(store.isActionDispatched(action)).toBe(true);
});
});
});
import React from 'react';
import { connect } from 'react-redux';
import { mountWithState } from 'enzyme-redux';
describe('example mountWithState', () => {
const ReactComponent = () => (<div>dummy component</div>);
it('works', () => {
const expectedState = 'expectedState';
const mapStateToProps = (state) => ({
state,
});
const ConnectedComponent = connect(mapStateToProps)(ReactComponent);
const component = mountWithState(<ConnectedComponent />, expectedState);
expect(component.props().state).toBe(expectedState);
});
});
FAQs
Test utils to simplify testing of containers in redux with enzyme.
The npm package enzyme-redux receives a total of 1,304 weekly downloads. As such, enzyme-redux popularity was classified as popular.
We found that enzyme-redux demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
Security News
Socket CEO Feross Aboukhadijeh discusses open source security challenges, including zero-day attacks and supply chain risks, on the Cyber Security Council podcast.
Security News
Research
Socket researchers uncover how threat actors weaponize Out-of-Band Application Security Testing (OAST) techniques across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.