Skip to content
This repository has been archived by the owner on Nov 9, 2019. It is now read-only.

Commit

Permalink
Add source files in lib and es directory with flow annotations.
Browse files Browse the repository at this point in the history
Add flow-typed directory with flow types of dependencies.
Update README and API.
  • Loading branch information
MrEfrem committed Nov 30, 2016
1 parent 4743abe commit dcc5de6
Show file tree
Hide file tree
Showing 43 changed files with 7,147 additions and 68 deletions.
6 changes: 4 additions & 2 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@
"es6": true
},
"plugins": [
"react"
"react",
"flowtype"
],
"extends": [
"eslint:recommended",
"plugin:import/errors",
"plugin:import/warnings",
"plugin:react/recommended"
"plugin:react/recommended",
"plugin:flowtype/recommended"
],
"rules": {
"indent": [2, 2, {
Expand Down
3 changes: 3 additions & 0 deletions .flowconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[libs]
flow-typed

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { Provider } from 'react-redux';
import { enhanceStore } from 'redux-fly';
import Counter from './Counter';

const store = createStore(null, enhanceStore);
const store = createStore(() => {}, enhanceStore);

export default () => (
<Provider store={store}>
Expand Down
58 changes: 29 additions & 29 deletions __tests__/createReducer.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ test('Test valid init component with provide is pure redux store', () => {
})

test('Test valid init component with provide enhanced redux store', () => {
const store = createStore(null, enhanceStore)
const store = createStore(() => {}, enhanceStore)

const Component = (props) => (
<div>
Expand Down Expand Up @@ -151,7 +151,7 @@ test('Test valid init component with provide enhanced redux store', () => {
})

test('Test passed mounting path in Component', () => {
const store = createStore(null, enhanceStore)
const store = createStore(() => {}, enhanceStore)

const Component = (props) => (
<div>{props.reduxMountPath}</div>
Expand All @@ -170,7 +170,7 @@ test('Test passed mounting path in Component', () => {
})

test('Test passed mounting path in createReducer and in Component', () => {
const store = createStore(null, enhanceStore)
const store = createStore(() => {}, enhanceStore)

const Component = (props) => (
<div>{props.reduxMountPath}</div>
Expand All @@ -191,7 +191,7 @@ test('Test passed mounting path in createReducer and in Component', () => {
})

test('Test passed persist in createReducer', () => {
const store = createStore(null, enhanceStore)
const store = createStore(() => {}, enhanceStore)

const Component = (props) => (
<div>{props.reduxPersist.toString()}</div>
Expand All @@ -210,7 +210,7 @@ test('Test passed persist in createReducer', () => {
})

test('Test passed persist in Component', () => {
const store = createStore(null, enhanceStore)
const store = createStore(() => {}, enhanceStore)

const Component = (props) => (
<div>{props.reduxPersist.toString()}</div>
Expand All @@ -229,7 +229,7 @@ test('Test passed persist in Component', () => {
})

test('Test passed persist in createReducer and Component', () => {
const store = createStore(null, enhanceStore)
const store = createStore(() => {}, enhanceStore)

const Component = (props) => (
<div>{props.reduxPersist.toString()}</div>
Expand All @@ -248,7 +248,7 @@ test('Test passed persist in createReducer and Component', () => {
})

test('Test initialState is function', () => {
const store = createStore(null, enhanceStore)
const store = createStore(() => {}, enhanceStore)

const Component = (props) => (
<div>{JSON.stringify(props.reduxState)}</div>
Expand All @@ -267,7 +267,7 @@ test('Test initialState is function', () => {
})

test('Test listenActions', () => {
const store = createStore(null, enhanceStore)
const store = createStore(() => {}, enhanceStore)
const UPDATE_TODO = 'UPDATE_TODO'

class Component extends React.Component {
Expand Down Expand Up @@ -303,7 +303,7 @@ test('Test listenActions', () => {
})

test('Test listenActions is function', () => {
const store = createStore(null, enhanceStore)
const store = createStore(() => {}, enhanceStore)
const UPDATE_TODO = 'UPDATE_TODO'

class Component extends React.Component {
Expand Down Expand Up @@ -341,7 +341,7 @@ test('Test listenActions is function', () => {
})

test('Test listenActions is function in reusable component', () => {
const store = createStore(null, enhanceStore)
const store = createStore(() => {}, enhanceStore)
const UPDATE_TODO = 'UPDATE_TODO'

class Component extends React.Component {
Expand Down Expand Up @@ -379,7 +379,7 @@ test('Test listenActions is function in reusable component', () => {
})

test('Test connectToStore: false', () => {
const store = createStore(null, enhanceStore)
const store = createStore(() => {}, enhanceStore)

const Component = (props) => (
<div>{JSON.stringify(props.reduxState)}</div>
Expand All @@ -402,7 +402,7 @@ test('Test connectToStore: false', () => {
})

test('Test reset state (persist = false) after unmounting component', async () => {
const store = createStore(null, enhanceStore)
const store = createStore(() => {}, enhanceStore)

class Component extends React.Component {
componentDidMount() {
Expand Down Expand Up @@ -435,7 +435,7 @@ test('Test reset state (persist = false) after unmounting component', async () =
})

test('Test preserved state (persist = true) after unmounting component', () => {
const store = createStore(null, enhanceStore)
const store = createStore(() => {}, enhanceStore)

class Component extends React.Component {
componentDidMount() {
Expand Down Expand Up @@ -475,7 +475,7 @@ test('Test empty (default) actionPrefix', () => {
expect(action.type).toBe('ui component/@@UPDATE-TODO')
}
}
const store = createStore(null, compose(applyMiddleware(middleware), enhanceStore))
const store = createStore(() => {}, compose(applyMiddleware(middleware), enhanceStore))

class Component extends React.Component {
componentDidMount() {
Expand Down Expand Up @@ -510,7 +510,7 @@ test('Test empty (default) actionPrefix', () => {
})

test('Test filled actionPrefix in createReducer', () => {
const store = createStore(null, enhanceStore)
const store = createStore(() => {}, enhanceStore)

const Component = ({ reduxActionPrefix }) => {
return <div>{reduxActionPrefix}</div>
Expand All @@ -533,7 +533,7 @@ test('Test filled actionPrefix in createReducer', () => {
})

test('Test filled actionPrefix in component', () => {
const store = createStore(null, enhanceStore)
const store = createStore(() => {}, enhanceStore)

const Component = ({ reduxActionPrefix }) => {
return <div>{reduxActionPrefix}</div>
Expand All @@ -555,7 +555,7 @@ test('Test filled actionPrefix in component', () => {
})

test('Test filled actionPrefix in component and createReducer', () => {
const store = createStore(null, enhanceStore)
const store = createStore(() => {}, enhanceStore)

const Component = ({ reduxActionPrefix }) => {
return <div>{reduxActionPrefix}</div>
Expand All @@ -578,7 +578,7 @@ test('Test filled actionPrefix in component and createReducer', () => {
})

test('Test reduxResetState', () => {
const store = createStore(null, enhanceStore)
const store = createStore(() => {}, enhanceStore)

class Component extends React.Component {
componentDidMount() {
Expand Down Expand Up @@ -626,7 +626,7 @@ test('Test reduxResetState', () => {
})

test('Test signature reduxSetState', () => {
const store = createStore(null, enhanceStore)
const store = createStore(() => {}, enhanceStore)

class Component extends React.Component {
componentDidMount() {
Expand Down Expand Up @@ -659,7 +659,7 @@ test('Test signature reduxSetState', () => {
})

test('Test reduxSetState', () => {
const store = createStore(null, enhanceStore)
const store = createStore(() => {}, enhanceStore)
let numRender = 0
class Component extends React.Component {
componentDidMount() {
Expand Down Expand Up @@ -706,7 +706,7 @@ test('Test reduxSetState', () => {
})

test('Test replace native state to redux state', () => {
const store = createStore(null, enhanceStore)
const store = createStore(() => {}, enhanceStore)

class Component extends React.Component {
constructor(props) {
Expand Down Expand Up @@ -751,7 +751,7 @@ test('Test replace native state to redux state', () => {
})

test('Test is valid re-create of reducer', () => {
const store = createStore(null, enhanceStore)
const store = createStore(() => {}, enhanceStore)
const Component = () => <div/>
const ExtendedComponent = createReducer({
mountPath: 'ui component',
Expand All @@ -771,7 +771,7 @@ test('Test is valid re-create of reducer', () => {
})

test('Test is invalid to create of reducer in same mounting path', () => {
const store = createStore(null, enhanceStore)
const store = createStore(() => {}, enhanceStore)
const Component = ({ children }) => <div>{children}</div>
Component.propTypes = {
children: PropTypes.element
Expand All @@ -791,7 +791,7 @@ test('Test is invalid to create of reducer in same mounting path', () => {
})

test('Test is invalid to create of reducer in partially same mounting path (1)', () => {
const store = createStore(null, enhanceStore)
const store = createStore(() => {}, enhanceStore)
const Component = ({ children }) => <div>{children}</div>
Component.propTypes = {
children: PropTypes.element
Expand All @@ -816,7 +816,7 @@ test('Test is invalid to create of reducer in partially same mounting path (1)',
})

test('Test is invalid to create of reducer in partially same mounting path (2)', () => {
const store = createStore(null, enhanceStore)
const store = createStore(() => {}, enhanceStore)
const Component = ({ children }) => <div>{children}</div>
Component.propTypes = {
children: PropTypes.element
Expand All @@ -841,7 +841,7 @@ test('Test is invalid to create of reducer in partially same mounting path (2)',
})

test('Test is valid to create of reducer after create of reducer', () => {
const store = createStore(null, enhanceStore)
const store = createStore(() => {}, enhanceStore)
const Component = ({ children }) => <div>{children || 'Last reducer'}</div>
Component.propTypes = {
children: PropTypes.element
Expand All @@ -866,7 +866,7 @@ test('Test is valid to create of reducer after create of reducer', () => {
})

test('Test is invalid to set the mountPath for reused component which contains in other reused component (reduxMountPath + mountPath)', () => {
const store = createStore(null, enhanceStore)
const store = createStore(() => {}, enhanceStore)
const Component = ({ children }) => <div>{children || 'Last reducer'}</div>
Component.propTypes = {
children: PropTypes.element
Expand All @@ -890,7 +890,7 @@ test('Test is invalid to set the mountPath for reused component which contains i
})

test('Test is invalid to set the mountPath for reused component which contains in other reused component (reduxMountPath + reduxMountPath)', () => {
const store = createStore(null, enhanceStore)
const store = createStore(() => {}, enhanceStore)
const Component = ({ children }) => <div>{children || 'Last reducer'}</div>
Component.propTypes = {
children: PropTypes.element
Expand All @@ -914,7 +914,7 @@ test('Test is invalid to set the mountPath for reused component which contains i
})

test('Test is valid to set the mountPath for reused component which contains in other reused component', () => {
const store = createStore(null, enhanceStore)
const store = createStore(() => {}, enhanceStore)
const Component = ({ children, reduxMountPath }) => <div>{children ? React.cloneElement(children, { reduxMountPath }) : 'Last reducer'}</div>
Component.propTypes = {
children: PropTypes.element,
Expand Down
6 changes: 3 additions & 3 deletions __tests__/enhanceStore.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ test('Test invalid signature', () => {
})

test('Test invalid signature registerReducers', () => {
const store = createStore(null, enhanceStore)
const store = createStore(() => {}, enhanceStore)
expect(store.registerReducers).toThrowError('Reducers must be non empty plain object')
expect(store.registerReducers.bind(store, {})).toThrowError('Reducers must be non empty plain object')
expect(store.registerReducers.bind(store, Object.create({ ui: () => {} }))).toThrowError('Reducers must be non empty plain object')
Expand All @@ -23,7 +23,7 @@ test('Test invalid signature registerReducers', () => {
})

test('Test registerReducers', () => {
const store = createStore(null, null, enhanceStore)
const store = createStore(() => {}, null, enhanceStore)
const initialState1 = { text: 'My first todo' }
const initialState2 = { text: 'My second todo' }
const reducer1 = (state = initialState1, action) => {
Expand Down Expand Up @@ -61,7 +61,7 @@ test('Test registerReducers', () => {

test('Test createStore with preloadedState', () => {
const preloadedState = { ui: { todo: { text: 'My second todo' } } }
const store = createStore(null, preloadedState, enhanceStore)
const store = createStore(() => {}, preloadedState, enhanceStore)
const initialState = { text: 'My first todo' }
const reducer = (state = initialState) => state
store.registerReducers({
Expand Down
Loading

0 comments on commit dcc5de6

Please sign in to comment.