Skip to content

Commit

Permalink
Merge pull request reduxjs#236 from taylorhakes/shallow-equal-scalar-…
Browse files Browse the repository at this point in the history
…test

Added test for shallowEqualScalar in connect decorator
  • Loading branch information
gaearon committed Jul 9, 2015
2 parents 406ca62 + 038cd25 commit 5d5dbcc
Showing 1 changed file with 47 additions and 1 deletion.
48 changes: 47 additions & 1 deletion test/components/connect.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { connect, Connector } from '../../src/react';
const { TestUtils } = React.addons;

describe('React', () => {
describe('provide', () => {
describe('connect', () => {
jsdomReact();

// Mock minimal Provider interface
Expand Down Expand Up @@ -50,6 +50,52 @@ describe('React', () => {
).toNotThrow();
});

it('should handle additional prop changes in addition to slice', () => {
const store = createStore(() => ({
foo: 'bar'
}));

@connect(state => state)
class ConnectContainer extends Component {
render() {
return (
<div {...this.props} pass={this.props.bar.baz} />
);
}
}

class Container extends Component {
constructor() {
super();
this.state = {
bar: {
baz: ''
}
};
}
componentDidMount() {

// Simulate deep object mutation
this.state.bar.baz = 'through';
this.setState({
bar: this.state.bar
});
}
render() {
return (
<Provider store={store}>
{() => <ConnectContainer bar={this.state.bar} />}
</Provider>
);
}
}

const container = TestUtils.renderIntoDocument(<Container />);
const div = TestUtils.findRenderedDOMComponentWithTag(container, 'div');
expect(div.props.foo).toEqual('bar');
expect(div.props.pass).toEqual('through');
});

it('should pass the only argument as the select prop down', () => {
const store = createStore(() => ({
foo: 'baz',
Expand Down

0 comments on commit 5d5dbcc

Please sign in to comment.