-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
48 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,8 @@ | ||
import {connect} from 'react-redux'; | ||
import {connectIntl} from 'redux-intl-connect'; | ||
import {connect as reduxConnect} from 'react-redux'; | ||
import injectIntl from './injectIntl'; | ||
|
||
export default connectIntl(connect); | ||
function connect(...args) { | ||
return (Component) => reduxConnect(...args)(injectIntl(Component)); | ||
} | ||
|
||
export default connect; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import React from 'react'; | ||
import {expect} from 'chai'; | ||
import {shallow} from 'enzyme'; | ||
import {createStore, combineReducers} from 'redux'; | ||
import intlReducer from 'redux-intl-connect/lib/intlReducer'; | ||
import ValidateProp from './mocks/ValidateProp'; | ||
import Provider from '../src/Provider'; | ||
import connect from '../src/connect'; | ||
|
||
describe('connect', function () { | ||
it('should provide intl context', function () { | ||
const store = getStore(); | ||
const mapStateToProps = () => ({ | ||
others: ' too' | ||
}); | ||
const Component = connect(mapStateToProps)(ValidateProp); | ||
|
||
const App = () => ( | ||
<Provider store={store}> | ||
<Component /> | ||
</Provider> | ||
) | ||
const app = shallow(<App />) | ||
expect(app.html()).to.be.equal('<span>yes too</span>') | ||
}); | ||
|
||
function getStore() { | ||
const reducer = combineReducers({ | ||
intl: intlReducer, | ||
}) | ||
|
||
return createStore(reducer); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters