Skip to content

Commit 82e037e

Browse files
committed
fix: query params with same keys are added to the collection
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.
1 parent 3076885 commit 82e037e

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

Diff for: projects/testing-library/src/lib/testing-library.ts

+8-2
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,14 @@ export async function render<SutType, WrapperType = SutType>(
130130
const queryParams = params
131131
? params.split('&').reduce((qp, q) => {
132132
const [key, value] = q.split('=');
133-
// TODO(Breaking): group same keys qp[key] ? [...qp[key], value] : value
134-
qp[key] = value;
133+
const currentValue = qp[key];
134+
if (typeof currentValue === 'undefined') {
135+
qp[key] = value;
136+
} else if (Array.isArray(currentValue)) {
137+
qp[key] = [...currentValue, value];
138+
} else {
139+
qp[key] = [currentValue, value];
140+
}
135141
return qp;
136142
}, {})
137143
: undefined;

0 commit comments

Comments
 (0)