Skip to content

Commit

Permalink
Merge pull request #136 from sbason/commonjs-backwards-compatible
Browse files Browse the repository at this point in the history
Make CommonJS Version backwards compatible and Readme updates
  • Loading branch information
dmitry-zaets authored Jan 29, 2018
2 parents eb7fe9d + d6522eb commit 59e3110
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ npm install redux-mock-store --save-dev
The simplest usecase is for the synchronous actions. In this example, we will test if the `addTodo` action returns the right payload. `redux-mock-store` saves all the dispatched actions inside the store instance. You can get all the action by calling `store.getActions()`. Finally, you can use any assertion library to test the payload.

```js
import configureStore from 'redux-mock-store'
import configureStore from 'redux-mock-store' //ES6 modules
const { configureStore } = require('redux-mock-store') //CommonJS

const middlewares = []
const mockStore = configureStore(middlewares)
Expand Down Expand Up @@ -125,6 +126,13 @@ Follows the redux API

https://github.com/arnaudbenard/redux-mock-store/blob/v0.0.6/README.md

### Versions

The following versions are exposed by redux-mock-store from the `package.json`:

* `main`: commonJS Version
* `module`/`js:next`: ES Module Version
* `browser` : UMD version

## License

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
"browser": "dist/index.min.js",
"scripts": {
"prepublish": "rimraf lib && rimraf dist && npm run build",
"build:cjs": "cross-env BABEL_ENV=es NODE_ENV=production rollup -f cjs -c -i src/index.js -o dist/index-cjs.js",
"build:cjs": "babel src --out-file dist/index-cjs.js",
"build:umd": "cross-env BABEL_ENV=es NODE_ENV=development rollup -f umd -c -i src/index.js -o dist/index-umd.js",
"build:umd:min": "cross-env BABEL_ENV=es NODE_ENV=production rollup -f umd -c -i src/index.js -o dist/index-umd.min.js",
"build:es": "cross-env BABEL_ENV=es NODE_ENV=development rollup -f es -c -i src/index.js -o dist/index-es.js",
"build": "npm run build:cjs && npm run build:umd && npm run build:umd:min && npm run build:es",
"build": "npm run build:umd && npm run build:umd:min && npm run build:es && npm run build:cjs",
"lint": "standard src/*.js test/*.js",
"pretest": "npm run lint",
"test": "mocha --compilers js:babel-core/register --reporter spec test/*.js"
Expand Down
4 changes: 3 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import isPlainObject from 'lodash.isplainobject'

const isFunction = arg => typeof arg === 'function'

export default function configureStore (middlewares = []) {
export function configureStore (middlewares = []) {
return function mockStore (getState = {}) {
function mockStoreWithoutMiddleware () {
let actions = []
Expand Down Expand Up @@ -80,3 +80,5 @@ export default function configureStore (middlewares = []) {
return mockStoreWithMiddleware()
}
}

export default configureStore

0 comments on commit 59e3110

Please sign in to comment.