Skip to content

Commit

Permalink
fix: query params with same keys are added to the collection
Browse files Browse the repository at this point in the history
BREAKING CHANGE:

Query params on a router link with the same key are no longer overwriting the last value.
Instead they are added to an array.
  • Loading branch information
timdeschryver committed Dec 3, 2021
1 parent 3076885 commit 82e037e
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions projects/testing-library/src/lib/testing-library.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,14 @@ export async function render<SutType, WrapperType = SutType>(
const queryParams = params
? params.split('&').reduce((qp, q) => {
const [key, value] = q.split('=');
// TODO(Breaking): group same keys qp[key] ? [...qp[key], value] : value
qp[key] = value;
const currentValue = qp[key];
if (typeof currentValue === 'undefined') {
qp[key] = value;
} else if (Array.isArray(currentValue)) {
qp[key] = [...currentValue, value];
} else {
qp[key] = [currentValue, value];
}
return qp;
}, {})
: undefined;
Expand Down

0 comments on commit 82e037e

Please sign in to comment.