Skip to content

Commit

Permalink
fixing #78
Browse files Browse the repository at this point in the history
  • Loading branch information
tomkis committed May 23, 2017
1 parent f9f4328 commit e1bd952
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
29 changes: 29 additions & 0 deletions packages/prism-react/src/__tests__/enhanceComponent.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -163,4 +163,33 @@ describe('enhanceComponent', () => {
button.simulate('click');
expect(button.text()).toEqual('John Doe');
});

it('should not pass down selector and wrapper to enhanced Component', (done) => {
const identityReducer = (value : number = 42) => value;
const store = createStore(identityReducer);

interface SelectorWrapper {
selector: any,
wrapper: any
};

const EnhancedHelloWorld = enhanceComponent<void, void>(connect(
state => ({})
)((props : SelectorWrapper) => {
expect(props.selector).toBeUndefined();
expect(props.wrapper).toBeUndefined();

done();
return <div />;
}));

const component = mount(
<Provider store={store}>
<EnhancedHelloWorld
wrapper={type => type}
selector={state => state}
/>
</Provider>
)
});
});
4 changes: 3 additions & 1 deletion packages/prism-react/src/enhanceComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,11 @@ export default <P, S> (
}

render() {
const { selector, wrapper, ...rest } = this.props;

return createEagerElement(
EnhanceableComponent,
this.props
rest
);
}
}

0 comments on commit e1bd952

Please sign in to comment.