Skip to content

Commit

Permalink
fix(history-service): reorder createRootLocation params (#511)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: The currentRootLocation and consumerLocation
parameters of createRootLocation have been switched.
  • Loading branch information
unstubbable authored and clebert committed Jun 11, 2019
1 parent 7df042e commit 92d6070
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const rootLocationTransformer: RootLocationTransformer = {
return searchParams.get(consumerId) || undefined;
},

createRootLocation: (consumerLocation, rootLocation, consumerId) => {
createRootLocation: (rootLocation, consumerLocation, consumerId) => {
const searchParams = new URLSearchParams(rootLocation.search);

if (consumerLocation) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@ describe('#createRootLocationTransformer', () => {
});

let rootLocation = locationTransformer.createRootLocation(
{pathname: '/foo'} as Location,
{pathname: '/'} as Location,
{pathname: '/foo'} as Location,
'test:1'
);

rootLocation = locationTransformer.createRootLocation(
rootLocation as Location,
{
pathname: '/bar',
search: 'baz=1'
} as Location,
rootLocation as Location,
'test:2'
);

Expand All @@ -37,17 +37,17 @@ describe('#createRootLocationTransformer', () => {
});

let rootLocation = locationTransformer.createRootLocation(
{pathname: '/foo'} as Location,
{
pathname: '/',
search: '---=%7B%22test%3A2%22%3A%22%2Fbar%22%7D'
} as Location,
{pathname: '/foo'} as Location,
'test:1'
);

rootLocation = locationTransformer.createRootLocation(
undefined,
rootLocation as Location,
undefined,
'test:1'
);

Expand All @@ -63,20 +63,20 @@ describe('#createRootLocationTransformer', () => {
});

let rootLocation = locationTransformer.createRootLocation(
{pathname: '/foo'} as Location,
{pathname: '/'} as Location,
{pathname: '/foo'} as Location,
'test:1'
);

rootLocation = locationTransformer.createRootLocation(
undefined,
rootLocation as Location,
undefined,
'test:1'
);

rootLocation = locationTransformer.createRootLocation(
undefined,
rootLocation as Location,
undefined,
'test:1'
);

Expand All @@ -95,8 +95,8 @@ describe('#createRootLocationTransformer', () => {
});

const rootLocation = locationTransformer.createRootLocation(
{pathname: '/foo', search: 'bar=1&baz=2', hash: '#qux'} as Location,
{pathname: '/'} as Location,
{pathname: '/foo', search: 'bar=1&baz=2', hash: '#qux'} as Location,
'test:pri'
);

Expand All @@ -114,14 +114,14 @@ describe('#createRootLocationTransformer', () => {
});

let rootLocation = locationTransformer.createRootLocation(
{pathname: '/foo', search: 'bar=1&baz=2', hash: '#qux'} as Location,
{pathname: '/'} as Location,
{pathname: '/foo', search: 'bar=1&baz=2', hash: '#qux'} as Location,
'test:pri'
);

rootLocation = locationTransformer.createRootLocation(
undefined,
rootLocation as Location,
undefined,
'test:pri'
);

Expand All @@ -137,8 +137,8 @@ describe('#createRootLocationTransformer', () => {

expect(() =>
locationTransformer.createRootLocation(
{pathname: '/foo', search: '---=1'} as Location,
{pathname: '/'} as Location,
{pathname: '/foo', search: '---=1'} as Location,
'test:pri'
)
).toThrowError(
Expand All @@ -158,20 +158,20 @@ describe('#createRootLocationTransformer', () => {
});

let rootLocation = locationTransformer.createRootLocation(
{pathname: '/baz', search: 'qux=3'} as Location,
{pathname: '/'} as Location,
{pathname: '/baz', search: 'qux=3'} as Location,
'test:1'
);

rootLocation = locationTransformer.createRootLocation(
{pathname: '/foo', search: 'bar=1', hash: '#qux'} as Location,
rootLocation as Location,
{pathname: '/foo', search: 'bar=1', hash: '#qux'} as Location,
'test:pri'
);

rootLocation = locationTransformer.createRootLocation(
{pathname: '/some', search: 'thing=else'} as Location,
rootLocation as Location,
{pathname: '/some', search: 'thing=else'} as Location,
'test:2'
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ export interface RootLocationTransformer {
): string | undefined;

createRootLocation(
consumerLocation: history.Location | undefined,
currentRootLocation: history.Location,
consumerLocation: history.Location | undefined,
consumerId: string
): history.LocationDescriptorObject;
}
Expand Down Expand Up @@ -129,8 +129,8 @@ export function createRootLocationTransformer(
},

createRootLocation: (
consumerLocation: history.Location | undefined,
currentRootLocation: history.Location,
consumerLocation: history.Location | undefined,
consumerId: string
): history.LocationDescriptorObject => {
const {consumerPathsQueryParamName, primaryConsumerId} = options;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ export class HistoryMultiplexer {
consumerLocation: history.Location | undefined
): history.Location {
const rootLocation = this.rootLocationTransformer.createRootLocation(
consumerLocation,
this.rootHistory.location,
consumerLocation,
consumerId
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const testRootLocationTransformer: RootLocationTransformer = {
return searchParams.get(consumerId) || undefined;
},

createRootLocation: (consumerLocation, rootLocation, consumerId) => {
createRootLocation: (rootLocation, consumerLocation, consumerId) => {
const searchParams = new URLSearchParams(rootLocation.search);

if (consumerLocation) {
Expand Down

0 comments on commit 92d6070

Please sign in to comment.