You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-08-06 12:02:40 +03:00
Update dependency fetch-mock to v10 (#4276)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
@@ -106,7 +106,7 @@
|
|||||||
"eslint-plugin-tsdoc": "^0.3.0",
|
"eslint-plugin-tsdoc": "^0.3.0",
|
||||||
"eslint-plugin-unicorn": "^53.0.0",
|
"eslint-plugin-unicorn": "^53.0.0",
|
||||||
"fake-indexeddb": "^5.0.2",
|
"fake-indexeddb": "^5.0.2",
|
||||||
"fetch-mock": "9.11.0",
|
"fetch-mock": "10.0.7",
|
||||||
"fetch-mock-jest": "^1.5.1",
|
"fetch-mock-jest": "^1.5.1",
|
||||||
"husky": "^9.0.0",
|
"husky": "^9.0.0",
|
||||||
"jest": "^29.0.0",
|
"jest": "^29.0.0",
|
||||||
|
@@ -19,7 +19,7 @@ import anotherjson from "another-json";
|
|||||||
import fetchMock from "fetch-mock-jest";
|
import fetchMock from "fetch-mock-jest";
|
||||||
import "fake-indexeddb/auto";
|
import "fake-indexeddb/auto";
|
||||||
import { IDBFactory } from "fake-indexeddb";
|
import { IDBFactory } from "fake-indexeddb";
|
||||||
import { MockResponse, MockResponseFunction } from "fetch-mock";
|
import FetchMock from "fetch-mock";
|
||||||
import Olm from "@matrix-org/olm";
|
import Olm from "@matrix-org/olm";
|
||||||
|
|
||||||
import * as testUtils from "../../test-utils/test-utils";
|
import * as testUtils from "../../test-utils/test-utils";
|
||||||
@@ -157,7 +157,7 @@ async function expectSendRoomKey(
|
|||||||
return await new Promise<Olm.InboundGroupSession>((resolve) => {
|
return await new Promise<Olm.InboundGroupSession>((resolve) => {
|
||||||
fetchMock.putOnce(
|
fetchMock.putOnce(
|
||||||
new RegExp("/sendToDevice/m.room.encrypted/"),
|
new RegExp("/sendToDevice/m.room.encrypted/"),
|
||||||
(url: string, opts: RequestInit): MockResponse => {
|
(url: string, opts: RequestInit): FetchMock.MockResponse => {
|
||||||
const content = JSON.parse(opts.body as string);
|
const content = JSON.parse(opts.body as string);
|
||||||
resolve(onSendRoomKey(content));
|
resolve(onSendRoomKey(content));
|
||||||
return {};
|
return {};
|
||||||
@@ -291,7 +291,7 @@ describe.each(Object.entries(CRYPTO_BACKENDS))("crypto (%s)", (backend: string,
|
|||||||
* @param response - the response to return from the request. Normally an {@link IClaimOTKsResult}
|
* @param response - the response to return from the request. Normally an {@link IClaimOTKsResult}
|
||||||
* (or a function that returns one).
|
* (or a function that returns one).
|
||||||
*/
|
*/
|
||||||
function expectAliceKeyClaim(response: MockResponse | MockResponseFunction) {
|
function expectAliceKeyClaim(response: FetchMock.MockResponse | FetchMock.MockResponseFunction) {
|
||||||
const rootRegexp = escapeRegExp(new URL("/_matrix/client/", aliceClient.getHomeserverUrl()).toString());
|
const rootRegexp = escapeRegExp(new URL("/_matrix/client/", aliceClient.getHomeserverUrl()).toString());
|
||||||
fetchMock.postOnce(new RegExp(rootRegexp + "(r0|v3)/keys/claim"), response);
|
fetchMock.postOnce(new RegExp(rootRegexp + "(r0|v3)/keys/claim"), response);
|
||||||
}
|
}
|
||||||
@@ -1419,7 +1419,7 @@ describe.each(Object.entries(CRYPTO_BACKENDS))("crypto (%s)", (backend: string,
|
|||||||
|
|
||||||
fetchMock.putOnce(
|
fetchMock.putOnce(
|
||||||
{ url: new RegExp("/send/"), name: "send-event" },
|
{ url: new RegExp("/send/"), name: "send-event" },
|
||||||
(url: string, opts: RequestInit): MockResponse => {
|
(url: string, opts: RequestInit): FetchMock.MockResponse => {
|
||||||
const content = JSON.parse(opts.body as string);
|
const content = JSON.parse(opts.body as string);
|
||||||
logger.log("/send:", content);
|
logger.log("/send:", content);
|
||||||
// make sure that a new session is used
|
// make sure that a new session is used
|
||||||
@@ -1484,7 +1484,7 @@ describe.each(Object.entries(CRYPTO_BACKENDS))("crypto (%s)", (backend: string,
|
|||||||
|
|
||||||
// mark the device as known, and resend.
|
// mark the device as known, and resend.
|
||||||
aliceClient.setDeviceKnown(aliceClient.getUserId()!, "DEVICE_ID");
|
aliceClient.setDeviceKnown(aliceClient.getUserId()!, "DEVICE_ID");
|
||||||
expectAliceKeyClaim((url: string, opts: RequestInit): MockResponse => {
|
expectAliceKeyClaim((url: string, opts: RequestInit): FetchMock.MockResponse => {
|
||||||
const content = JSON.parse(opts.body as string);
|
const content = JSON.parse(opts.body as string);
|
||||||
expect(content.one_time_keys[aliceClient.getUserId()!].DEVICE_ID).toEqual("signed_curve25519");
|
expect(content.one_time_keys[aliceClient.getUserId()!].DEVICE_ID).toEqual("signed_curve25519");
|
||||||
return getTestKeysClaimResponse(aliceClient.getUserId()!);
|
return getTestKeysClaimResponse(aliceClient.getUserId()!);
|
||||||
@@ -2180,11 +2180,11 @@ describe.each(Object.entries(CRYPTO_BACKENDS))("crypto (%s)", (backend: string,
|
|||||||
const inboundGroupSessionPromise = expectSendRoomKey("@bob:xyz", testOlmAccount);
|
const inboundGroupSessionPromise = expectSendRoomKey("@bob:xyz", testOlmAccount);
|
||||||
|
|
||||||
// ... and finally, send the room key. We block the response until `sendRoomMessageDefer` completes.
|
// ... and finally, send the room key. We block the response until `sendRoomMessageDefer` completes.
|
||||||
const sendRoomMessageDefer = defer<MockResponse>();
|
const sendRoomMessageDefer = defer<FetchMock.MockResponse>();
|
||||||
const reqProm = new Promise<IContent>((resolve) => {
|
const reqProm = new Promise<IContent>((resolve) => {
|
||||||
fetchMock.putOnce(
|
fetchMock.putOnce(
|
||||||
new RegExp("/send/m.room.encrypted/"),
|
new RegExp("/send/m.room.encrypted/"),
|
||||||
async (url: string, opts: RequestInit): Promise<MockResponse> => {
|
async (url: string, opts: RequestInit): Promise<FetchMock.MockResponse> => {
|
||||||
resolve(JSON.parse(opts.body as string));
|
resolve(JSON.parse(opts.body as string));
|
||||||
return await sendRoomMessageDefer.promise;
|
return await sendRoomMessageDefer.promise;
|
||||||
},
|
},
|
||||||
|
@@ -17,7 +17,7 @@ limitations under the License.
|
|||||||
import "fake-indexeddb/auto";
|
import "fake-indexeddb/auto";
|
||||||
|
|
||||||
import anotherjson from "another-json";
|
import anotherjson from "another-json";
|
||||||
import { MockResponse } from "fetch-mock";
|
import FetchMock from "fetch-mock";
|
||||||
import fetchMock from "fetch-mock-jest";
|
import fetchMock from "fetch-mock-jest";
|
||||||
import { IDBFactory } from "fake-indexeddb";
|
import { IDBFactory } from "fake-indexeddb";
|
||||||
import { createHash } from "crypto";
|
import { createHash } from "crypto";
|
||||||
@@ -1511,7 +1511,7 @@ function expectSendToDeviceMessage(msgtype: string): Promise<{ messages: any }>
|
|||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
fetchMock.putOnce(
|
fetchMock.putOnce(
|
||||||
new RegExp(`/_matrix/client/(r0|v3)/sendToDevice/${escapeRegExp(msgtype)}`),
|
new RegExp(`/_matrix/client/(r0|v3)/sendToDevice/${escapeRegExp(msgtype)}`),
|
||||||
(url: string, opts: RequestInit): MockResponse => {
|
(url: string, opts: RequestInit): FetchMock.MockResponse => {
|
||||||
resolve(JSON.parse(opts.body as string));
|
resolve(JSON.parse(opts.body as string));
|
||||||
return {};
|
return {};
|
||||||
},
|
},
|
||||||
@@ -1535,7 +1535,7 @@ function mockSecretRequestAndGetPromises(): Map<string, Promise<string>> {
|
|||||||
|
|
||||||
fetchMock.put(
|
fetchMock.put(
|
||||||
new RegExp(`/_matrix/client/(r0|v3)/sendToDevice/m.secret.request`),
|
new RegExp(`/_matrix/client/(r0|v3)/sendToDevice/m.secret.request`),
|
||||||
(url: string, opts: RequestInit): MockResponse => {
|
(url: string, opts: RequestInit): FetchMock.MockResponse => {
|
||||||
const messages = JSON.parse(opts.body as string).messages[TEST_USER_ID];
|
const messages = JSON.parse(opts.body as string).messages[TEST_USER_ID];
|
||||||
// rust crypto broadcasts to all devices, old crypto to a specific device, take the first one
|
// rust crypto broadcasts to all devices, old crypto to a specific device, take the first one
|
||||||
const content = Object.values(messages)[0] as any;
|
const content = Object.values(messages)[0] as any;
|
||||||
|
@@ -15,7 +15,6 @@ limitations under the License.
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import fetchMock from "fetch-mock-jest";
|
import fetchMock from "fetch-mock-jest";
|
||||||
import { MockOptionsMethodPut } from "fetch-mock";
|
|
||||||
|
|
||||||
import { ISyncResponder } from "./SyncResponder";
|
import { ISyncResponder } from "./SyncResponder";
|
||||||
|
|
||||||
@@ -40,7 +39,10 @@ export class AccountDataAccumulator {
|
|||||||
* @param opts - options to pass to fetchMock
|
* @param opts - options to pass to fetchMock
|
||||||
* @returns a Promise which will resolve (with the content of the account data) once it is set.
|
* @returns a Promise which will resolve (with the content of the account data) once it is set.
|
||||||
*/
|
*/
|
||||||
public interceptSetAccountData(accountDataType: string, opts?: MockOptionsMethodPut): Promise<any> {
|
public interceptSetAccountData(
|
||||||
|
accountDataType: string,
|
||||||
|
opts?: Parameters<(typeof fetchMock)["put"]>[2],
|
||||||
|
): Promise<any> {
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
// Called when the cross signing key is uploaded
|
// Called when the cross signing key is uploaded
|
||||||
fetchMock.put(
|
fetchMock.put(
|
||||||
|
@@ -17,7 +17,7 @@ limitations under the License.
|
|||||||
import debugFunc from "debug";
|
import debugFunc from "debug";
|
||||||
import { Debugger } from "debug";
|
import { Debugger } from "debug";
|
||||||
import fetchMock from "fetch-mock-jest";
|
import fetchMock from "fetch-mock-jest";
|
||||||
import { MockResponse } from "fetch-mock";
|
import FetchMock from "fetch-mock";
|
||||||
|
|
||||||
/** Interface implemented by classes that intercept `/sync` requests from test clients
|
/** Interface implemented by classes that intercept `/sync` requests from test clients
|
||||||
*
|
*
|
||||||
@@ -80,7 +80,7 @@ export class SyncResponder implements ISyncResponder {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async onSyncRequest(): Promise<MockResponse> {
|
private async onSyncRequest(): Promise<FetchMock.MockResponse> {
|
||||||
switch (this.state) {
|
switch (this.state) {
|
||||||
case SyncResponderState.IDLE: {
|
case SyncResponderState.IDLE: {
|
||||||
this.debug("Got /sync request: waiting for response to be ready");
|
this.debug("Got /sync request: waiting for response to be ready");
|
||||||
|
16
yarn.lock
16
yarn.lock
@@ -3663,7 +3663,19 @@ fetch-mock-jest@^1.5.1:
|
|||||||
dependencies:
|
dependencies:
|
||||||
fetch-mock "^9.11.0"
|
fetch-mock "^9.11.0"
|
||||||
|
|
||||||
fetch-mock@9.11.0, fetch-mock@^9.11.0:
|
fetch-mock@10.0.7:
|
||||||
|
version "10.0.7"
|
||||||
|
resolved "https://registry.yarnpkg.com/fetch-mock/-/fetch-mock-10.0.7.tgz#b274aaebe5b59c641f02d836b579bbe9b063f8db"
|
||||||
|
integrity sha512-TFG42kMRJ6dZpUDeVTdXNjh5O4TchHU/UNk41a050TwKzRr5RJQbtckXDjXiQFHPKgXGUG5l2TY3ZZ2gokiXaQ==
|
||||||
|
dependencies:
|
||||||
|
debug "^4.1.1"
|
||||||
|
glob-to-regexp "^0.4.0"
|
||||||
|
is-subset "^0.1.1"
|
||||||
|
lodash.isequal "^4.5.0"
|
||||||
|
path-to-regexp "^2.2.1"
|
||||||
|
querystring "^0.2.1"
|
||||||
|
|
||||||
|
fetch-mock@^9.11.0:
|
||||||
version "9.11.0"
|
version "9.11.0"
|
||||||
resolved "https://registry.yarnpkg.com/fetch-mock/-/fetch-mock-9.11.0.tgz#371c6fb7d45584d2ae4a18ee6824e7ad4b637a3f"
|
resolved "https://registry.yarnpkg.com/fetch-mock/-/fetch-mock-9.11.0.tgz#371c6fb7d45584d2ae4a18ee6824e7ad4b637a3f"
|
||||||
integrity sha512-PG1XUv+x7iag5p/iNHD4/jdpxL9FtVSqRMUQhPab4hVDt80T1MH5ehzVrL2IdXO9Q2iBggArFvPqjUbHFuI58Q==
|
integrity sha512-PG1XUv+x7iag5p/iNHD4/jdpxL9FtVSqRMUQhPab4hVDt80T1MH5ehzVrL2IdXO9Q2iBggArFvPqjUbHFuI58Q==
|
||||||
@@ -5680,7 +5692,7 @@ pvutils@^1.1.3:
|
|||||||
resolved "https://registry.yarnpkg.com/pvutils/-/pvutils-1.1.3.tgz#f35fc1d27e7cd3dfbd39c0826d173e806a03f5a3"
|
resolved "https://registry.yarnpkg.com/pvutils/-/pvutils-1.1.3.tgz#f35fc1d27e7cd3dfbd39c0826d173e806a03f5a3"
|
||||||
integrity sha512-pMpnA0qRdFp32b1sJl1wOJNxZLQ2cbQx+k6tjNtZ8CpvVhNqEPRgivZ2WOUev2YMajecdH7ctUPDvEe87nariQ==
|
integrity sha512-pMpnA0qRdFp32b1sJl1wOJNxZLQ2cbQx+k6tjNtZ8CpvVhNqEPRgivZ2WOUev2YMajecdH7ctUPDvEe87nariQ==
|
||||||
|
|
||||||
querystring@^0.2.0:
|
querystring@^0.2.0, querystring@^0.2.1:
|
||||||
version "0.2.1"
|
version "0.2.1"
|
||||||
resolved "https://registry.yarnpkg.com/querystring/-/querystring-0.2.1.tgz#40d77615bb09d16902a85c3e38aa8b5ed761c2dd"
|
resolved "https://registry.yarnpkg.com/querystring/-/querystring-0.2.1.tgz#40d77615bb09d16902a85c3e38aa8b5ed761c2dd"
|
||||||
integrity sha512-wkvS7mL/JMugcup3/rMitHmd9ecIGd2lhFhK9N3UUQ450h66d1r3Y9nvXzQAW1Lq+wyx61k/1pfKS5KuKiyEbg==
|
integrity sha512-wkvS7mL/JMugcup3/rMitHmd9ecIGd2lhFhK9N3UUQ450h66d1r3Y9nvXzQAW1Lq+wyx61k/1pfKS5KuKiyEbg==
|
||||||
|
Reference in New Issue
Block a user