diff --git a/src/index.js b/src/index.js index 495ec76..a2e007c 100644 --- a/src/index.js +++ b/src/index.js @@ -1,9 +1,9 @@ -const deepEqual = require('deep-equal') +import deepEqual from 'deep-equal' // Constants const INIT_PATH = '@@router/INIT_PATH' -const UPDATE_PATH = '@@router/UPDATE_PATH' +export const UPDATE_PATH = '@@router/UPDATE_PATH' const SELECT_STATE = state => state.routing // Action creators @@ -20,7 +20,7 @@ function initPath(path, state) { } } -function pushPath(path, state, { avoidRouterUpdate = false } = {}) { +export function pushPath(path, state, { avoidRouterUpdate = false } = {}) { return { type: UPDATE_PATH, payload: { @@ -32,7 +32,7 @@ function pushPath(path, state, { avoidRouterUpdate = false } = {}) { } } -function replacePath(path, state, { avoidRouterUpdate = false } = {}) { +export function replacePath(path, state, { avoidRouterUpdate = false } = {}) { return { type: UPDATE_PATH, payload: { @@ -81,7 +81,7 @@ function createPath(location) { return result } -function syncReduxAndRouter(history, store, selectRouterState = SELECT_STATE) { +export function syncReduxAndRouter(history, store, selectRouterState = SELECT_STATE) { const getRouterState = () => selectRouterState(store.getState()) // To properly handle store updates we need to track the last route. @@ -158,10 +158,4 @@ function syncReduxAndRouter(history, store, selectRouterState = SELECT_STATE) { } } -module.exports = { - UPDATE_PATH, - pushPath, - replacePath, - syncReduxAndRouter, - routeReducer: update -} +export { update as routeReducer } diff --git a/test/browser/index.js b/test/browser/index.js index 3a0b469..5310155 100644 --- a/test/browser/index.js +++ b/test/browser/index.js @@ -1,5 +1,5 @@ -const { createHashHistory, createHistory } = require('history') -const createTests = require('../createTests.js') +import { createHashHistory, createHistory } from 'history' +import createTests from '../createTests.js' createTests(createHashHistory, 'Hash History', () => window.location = '#/') createTests(createHistory, 'Browser History', () => window.history.replaceState(null, null, '/')) diff --git a/test/createTests.js b/test/createTests.js index 4af921e..346ca61 100644 --- a/test/createTests.js +++ b/test/createTests.js @@ -1,11 +1,11 @@ /*eslint-env mocha */ -const expect = require('expect') -const { pushPath, replacePath, UPDATE_PATH, routeReducer, syncReduxAndRouter } = require('../src/index') -const { createStore, combineReducers, compose } = require('redux') -const { devTools } = require('redux-devtools') -const { ActionCreators } = require('redux-devtools/lib/devTools') -const { useBasename } = require('history') +import expect from 'expect' +import { pushPath, replacePath, UPDATE_PATH, routeReducer, syncReduxAndRouter } from '../src/index' +import { createStore, combineReducers, compose } from 'redux' +import { devTools } from 'redux-devtools' +import { ActionCreators } from 'redux-devtools/lib/devTools' +import { useBasename } from 'history' expect.extend({ toContainRoute({ diff --git a/test/node/index.js b/test/node/index.js index e7739ca..fe092ba 100644 --- a/test/node/index.js +++ b/test/node/index.js @@ -1,4 +1,4 @@ -const { createMemoryHistory } = require('history') -const createTests = require('../createTests.js') +import { createMemoryHistory } from 'history' +import createTests from '../createTests.js' createTests(createMemoryHistory, 'Memory History')