You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-07-31 15:24:23 +03:00
Rename convertQueryDictToMap
This commit is contained in:
@ -68,9 +68,9 @@ jest.mock("../../src/webrtc/call", () => ({
|
|||||||
supportsMatrixCall: jest.fn(() => false),
|
supportsMatrixCall: jest.fn(() => false),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// Utility function to ease the transition from our QueryDict type to a string record
|
// Utility function to ease the transition from our QueryDict type to a Map
|
||||||
// which we can use to stringify with URLSearchParams
|
// which we can use to build a URLSearchParams
|
||||||
function convertQueryDictToStringRecord(queryDict?: QueryDict): Map<string, string> {
|
function convertQueryDictToMap(queryDict?: QueryDict): Map<string, string> {
|
||||||
if (!queryDict) {
|
if (!queryDict) {
|
||||||
return new Map();
|
return new Map();
|
||||||
}
|
}
|
||||||
@ -100,15 +100,15 @@ type WrappedRoom = Room & {
|
|||||||
|
|
||||||
describe("convertQueryDictToStringRecord", () => {
|
describe("convertQueryDictToStringRecord", () => {
|
||||||
it("returns an empty map when dict is undefined", () => {
|
it("returns an empty map when dict is undefined", () => {
|
||||||
expect(convertQueryDictToStringRecord(undefined)).toEqual(new Map());
|
expect(convertQueryDictToMap(undefined)).toEqual(new Map());
|
||||||
});
|
});
|
||||||
|
|
||||||
it("converts an empty QueryDict to an empty map", () => {
|
it("converts an empty QueryDict to an empty map", () => {
|
||||||
expect(convertQueryDictToStringRecord({})).toEqual(new Map());
|
expect(convertQueryDictToMap({})).toEqual(new Map());
|
||||||
});
|
});
|
||||||
|
|
||||||
it("converts a QueryDict of strings to the equivalent map", () => {
|
it("converts a QueryDict of strings to the equivalent map", () => {
|
||||||
expect(convertQueryDictToStringRecord({ a: "b", c: "d" })).toEqual(
|
expect(convertQueryDictToMap({ a: "b", c: "d" })).toEqual(
|
||||||
new Map([
|
new Map([
|
||||||
["a", "b"],
|
["a", "b"],
|
||||||
["c", "d"],
|
["c", "d"],
|
||||||
@ -117,7 +117,7 @@ describe("convertQueryDictToStringRecord", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("converts the values of the supplied QueryDict to strings", () => {
|
it("converts the values of the supplied QueryDict to strings", () => {
|
||||||
expect(convertQueryDictToStringRecord({ arr: ["b", "c"], num: 45, boo: true, und: undefined })).toEqual(
|
expect(convertQueryDictToMap({ arr: ["b", "c"], num: 45, boo: true, und: undefined })).toEqual(
|
||||||
new Map([
|
new Map([
|
||||||
["arr", "b,c"],
|
["arr", "b,c"],
|
||||||
["num", "45"],
|
["num", "45"],
|
||||||
@ -128,7 +128,7 @@ describe("convertQueryDictToStringRecord", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("produces sane URLSearchParams conversions", () => {
|
it("produces sane URLSearchParams conversions", () => {
|
||||||
expect(new URLSearchParams(Array.from(convertQueryDictToStringRecord({ a: "b", c: "d" }))).toString()).toEqual(
|
expect(new URLSearchParams(Array.from(convertQueryDictToMap({ a: "b", c: "d" }))).toString()).toEqual(
|
||||||
"a=b&c=d",
|
"a=b&c=d",
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@ -255,11 +255,11 @@ describe("MatrixClient", function () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const receivedRequestQueryString = new URLSearchParams(
|
const receivedRequestQueryString = new URLSearchParams(
|
||||||
Array.from(convertQueryDictToStringRecord(queryParams)),
|
Array.from(convertQueryDictToMap(queryParams)),
|
||||||
).toString();
|
).toString();
|
||||||
const receivedRequestDebugString = `${method} ${prefix}${path}${receivedRequestQueryString}`;
|
const receivedRequestDebugString = `${method} ${prefix}${path}${receivedRequestQueryString}`;
|
||||||
const expectedQueryString = new URLSearchParams(
|
const expectedQueryString = new URLSearchParams(
|
||||||
Array.from(convertQueryDictToStringRecord(next.expectQueryParams)),
|
Array.from(convertQueryDictToMap(next.expectQueryParams)),
|
||||||
).toString();
|
).toString();
|
||||||
const expectedRequestDebugString = `${next.method} ${next.prefix ?? ""}${next.path}${expectedQueryString}`;
|
const expectedRequestDebugString = `${next.method} ${next.prefix ?? ""}${next.path}${expectedQueryString}`;
|
||||||
// If you're seeing this then you forgot to handle at least 1 pending request.
|
// If you're seeing this then you forgot to handle at least 1 pending request.
|
||||||
|
Reference in New Issue
Block a user