-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #41 from 4Catalyzer/update
Update query-string and other dependencies
- Loading branch information
Showing
8 changed files
with
4,364 additions
and
40 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,7 +1,7 @@ | ||
{ | ||
"presets": [ | ||
["latest", { | ||
"es2015": { "loose": true } | ||
["env", { | ||
"loose": true | ||
}], | ||
"stage-1" | ||
], | ||
|
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
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
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
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
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,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; | ||
} |
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,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, | ||
}, | ||
}); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.