Skip to content

Commit

Permalink
Merge pull request #41 from 4Catalyzer/update
Browse files Browse the repository at this point in the history
Update query-string and other dependencies
  • Loading branch information
taion authored Oct 19, 2017
2 parents c839427 + 9eb8394 commit 17c164b
Show file tree
Hide file tree
Showing 8 changed files with 4,364 additions and 40 deletions.
4 changes: 2 additions & 2 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"presets": [
["latest", {
"es2015": { "loose": true }
["env", {
"loose": true
}],
"stage-1"
],
Expand Down
4 changes: 1 addition & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ env:
- BROWSER=ChromeCi
- BROWSER=Firefox

cache:
directories:
- node_modules
cache: yarn

before_install:
- export CHROME_BIN=chromium-browser
Expand Down
14 changes: 7 additions & 7 deletions examples/playground/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ import queryMiddleware from 'farce/lib/queryMiddleware';
import { bindActionCreators, combineReducers, createStore } from 'redux';

const store = createStore(
combineReducers({
location: locationReducer,
}),
createHistoryEnhancer({
protocol: new BrowserProtocol(),
middlewares: [queryMiddleware],
}),
combineReducers({
location: locationReducer,
}),
createHistoryEnhancer({
protocol: new BrowserProtocol(),
middlewares: [queryMiddleware],
}),
);

store.subscribe(() => {
Expand Down
7 changes: 3 additions & 4 deletions karma.conf.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// eslint-disable-next-line import/no-extraneous-dependencies
const webpack = require('webpack');
const webpack = require('webpack'); // eslint-disable-line import/no-extraneous-dependencies

module.exports = (config) => {
const { env } = process;
Expand All @@ -15,8 +14,8 @@ module.exports = (config) => {

webpack: {
module: {
loaders: [
{ test: /\.js$/, exclude: /node_modules/, loader: 'babel' },
rules: [
{ test: /\.js$/, exclude: /node_modules/, use: 'babel-loader' },
],
},
plugins: [
Expand Down
48 changes: 24 additions & 24 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,37 +31,37 @@
"dom-helpers": "^3.2.1",
"invariant": "^2.2.2",
"is-promise": "^2.1.0",
"query-string": "^4.3.2",
"redux": "^3.6.0"
"query-string": "^5.0.0",
"redux": "^3.7.2"
},
"devDependencies": {
"babel-cli": "^6.24.1",
"babel-core": "^6.24.1",
"babel-eslint": "^7.2.1",
"babel-loader": "^6.4.1",
"babel-cli": "^6.26.0",
"babel-core": "^6.26.0",
"babel-eslint": "^7.2.3",
"babel-loader": "^7.1.2",
"babel-plugin-add-module-exports": "^0.2.1",
"babel-plugin-dev-expression": "^0.2.1",
"babel-polyfill": "^6.23.0",
"babel-preset-latest": "^6.24.1",
"babel-polyfill": "^6.26.0",
"babel-preset-env": "^1.6.1",
"babel-preset-stage-1": "^6.24.1",
"chai": "^3.5.0",
"cross-env": "^4.0.0",
"dirty-chai": "^1.2.2",
"eslint": "^3.19.0",
"eslint-config-4catalyzer": "^0.2.0",
"eslint-plugin-import": "^2.2.0",
"karma": "^1.6.0",
"karma-chrome-launcher": "^2.0.0",
"chai": "^4.1.2",
"cross-env": "^5.1.0",
"dirty-chai": "^2.0.1",
"eslint": "^4.9.0",
"eslint-config-4catalyzer": "^0.3.3",
"eslint-plugin-import": "^2.8.0",
"karma": "^1.7.1",
"karma-chrome-launcher": "^2.2.0",
"karma-firefox-launcher": "^1.0.1",
"karma-mocha": "^1.3.0",
"karma-mocha-reporter": "^2.2.3",
"karma-sinon-chai": "^1.3.1",
"karma-mocha-reporter": "^2.2.5",
"karma-sinon-chai": "^1.3.2",
"karma-sourcemap-loader": "^0.3.7",
"karma-webpack": "^1.8.0",
"mocha": "^3.2.0",
"rimraf": "^2.6.1",
"sinon": "^2.1.0",
"sinon-chai": "^2.9.0",
"webpack": "^1.13.3"
"karma-webpack": "^2.0.5",
"mocha": "^4.0.1",
"rimraf": "^2.6.2",
"sinon": "^2.4.1",
"sinon-chai": "^2.14.0",
"webpack": "^3.8.1"
}
}
27 changes: 27 additions & 0 deletions test/helpers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import ActionTypes from '../src/ActionTypes';

export function invokeLocationMiddleware(middleware, action) {
let result;

function next(nextAction) {
result = nextAction;
}

middleware()(next)(action);

return result;
}

export function invokeMakeLocationDescriptor(middleware, location) {
return invokeLocationMiddleware(middleware, {
type: ActionTypes.TRANSITION,
payload: location,
}).payload;
}

export function invokeMakeLocation(middleware, location) {
return invokeLocationMiddleware(middleware, {
type: ActionTypes.UPDATE_LOCATION,
payload: location,
}).payload;
}
85 changes: 85 additions & 0 deletions test/queryMiddleware.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
import queryMiddleware from '../src/queryMiddleware';

import { invokeMakeLocation, invokeMakeLocationDescriptor } from './helpers';

describe('queryMiddleware', () => {
describe('makeLocationDescriptor', () => {
it('should create a search string', () => {
expect(invokeMakeLocationDescriptor(queryMiddleware, {
path: '/path',
query: {
foo: 'bar',
},
})).to.include({
path: '/path',
search: '?foo=bar',
});
});

it('should not modify the search string without a query', () => {
expect(invokeMakeLocationDescriptor(queryMiddleware, {
path: '/path',
search: '?foo',
})).to.include({
path: '/path',
search: '?foo',
});
});

it('should replace the existing search string', () => {
expect(invokeMakeLocationDescriptor(queryMiddleware, {
path: '/path',
query: {
foo: 'bar',
},
search: '?baz',
})).to.include({
path: '/path',
search: '?foo=bar',
});
});
});

describe('makeLocation', () => {
it('should create a search string', () => {
expect(invokeMakeLocation(queryMiddleware, {
path: '/path',
search: '?foo=bar',
})).to.deep.include({
path: '/path',
query: {
foo: 'bar',
},
});
});

it('should preserve the supplied query', () => {
expect(invokeMakeLocation(queryMiddleware, {
path: '/path',
query: {
foo: 'bar',
baz: undefined,
},
search: '?foo=bar',
})).to.deep.include({
path: '/path',
query: {
foo: 'bar',
baz: undefined,
},
});
});

it('should handle malformed search strings', () => {
expect(invokeMakeLocation(queryMiddleware, {
path: '/path',
search: '?%%7C',
})).to.deep.include({
path: '/path',
query: {
'%|': null,
},
});
});
});
});
Loading

0 comments on commit 17c164b

Please sign in to comment.