Skip to content

Commit 6417f4f

Browse files
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>
1 parent 4bae83f commit 6417f4f

File tree

6 files changed

+31
-17
lines changed

6 files changed

+31
-17
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@
106106
"eslint-plugin-tsdoc": "^0.3.0",
107107
"eslint-plugin-unicorn": "^53.0.0",
108108
"fake-indexeddb": "^5.0.2",
109-
"fetch-mock": "9.11.0",
109+
"fetch-mock": "10.0.7",
110110
"fetch-mock-jest": "^1.5.1",
111111
"husky": "^9.0.0",
112112
"jest": "^29.0.0",

spec/integ/crypto/crypto.spec.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import anotherjson from "another-json";
1919
import fetchMock from "fetch-mock-jest";
2020
import "fake-indexeddb/auto";
2121
import { IDBFactory } from "fake-indexeddb";
22-
import { MockResponse, MockResponseFunction } from "fetch-mock";
22+
import FetchMock from "fetch-mock";
2323
import Olm from "@matrix-org/olm";
2424

2525
import * as testUtils from "../../test-utils/test-utils";
@@ -157,7 +157,7 @@ async function expectSendRoomKey(
157157
return await new Promise<Olm.InboundGroupSession>((resolve) => {
158158
fetchMock.putOnce(
159159
new RegExp("/sendToDevice/m.room.encrypted/"),
160-
(url: string, opts: RequestInit): MockResponse => {
160+
(url: string, opts: RequestInit): FetchMock.MockResponse => {
161161
const content = JSON.parse(opts.body as string);
162162
resolve(onSendRoomKey(content));
163163
return {};
@@ -291,7 +291,7 @@ describe.each(Object.entries(CRYPTO_BACKENDS))("crypto (%s)", (backend: string,
291291
* @param response - the response to return from the request. Normally an {@link IClaimOTKsResult}
292292
* (or a function that returns one).
293293
*/
294-
function expectAliceKeyClaim(response: MockResponse | MockResponseFunction) {
294+
function expectAliceKeyClaim(response: FetchMock.MockResponse | FetchMock.MockResponseFunction) {
295295
const rootRegexp = escapeRegExp(new URL("/_matrix/client/", aliceClient.getHomeserverUrl()).toString());
296296
fetchMock.postOnce(new RegExp(rootRegexp + "(r0|v3)/keys/claim"), response);
297297
}
@@ -1419,7 +1419,7 @@ describe.each(Object.entries(CRYPTO_BACKENDS))("crypto (%s)", (backend: string,
14191419

14201420
fetchMock.putOnce(
14211421
{ url: new RegExp("/send/"), name: "send-event" },
1422-
(url: string, opts: RequestInit): MockResponse => {
1422+
(url: string, opts: RequestInit): FetchMock.MockResponse => {
14231423
const content = JSON.parse(opts.body as string);
14241424
logger.log("/send:", content);
14251425
// make sure that a new session is used
@@ -1484,7 +1484,7 @@ describe.each(Object.entries(CRYPTO_BACKENDS))("crypto (%s)", (backend: string,
14841484

14851485
// mark the device as known, and resend.
14861486
aliceClient.setDeviceKnown(aliceClient.getUserId()!, "DEVICE_ID");
1487-
expectAliceKeyClaim((url: string, opts: RequestInit): MockResponse => {
1487+
expectAliceKeyClaim((url: string, opts: RequestInit): FetchMock.MockResponse => {
14881488
const content = JSON.parse(opts.body as string);
14891489
expect(content.one_time_keys[aliceClient.getUserId()!].DEVICE_ID).toEqual("signed_curve25519");
14901490
return getTestKeysClaimResponse(aliceClient.getUserId()!);
@@ -2180,11 +2180,11 @@ describe.each(Object.entries(CRYPTO_BACKENDS))("crypto (%s)", (backend: string,
21802180
const inboundGroupSessionPromise = expectSendRoomKey("@bob:xyz", testOlmAccount);
21812181

21822182
// ... and finally, send the room key. We block the response until `sendRoomMessageDefer` completes.
2183-
const sendRoomMessageDefer = defer<MockResponse>();
2183+
const sendRoomMessageDefer = defer<FetchMock.MockResponse>();
21842184
const reqProm = new Promise<IContent>((resolve) => {
21852185
fetchMock.putOnce(
21862186
new RegExp("/send/m.room.encrypted/"),
2187-
async (url: string, opts: RequestInit): Promise<MockResponse> => {
2187+
async (url: string, opts: RequestInit): Promise<FetchMock.MockResponse> => {
21882188
resolve(JSON.parse(opts.body as string));
21892189
return await sendRoomMessageDefer.promise;
21902190
},

spec/integ/crypto/verification.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ limitations under the License.
1717
import "fake-indexeddb/auto";
1818

1919
import anotherjson from "another-json";
20-
import { MockResponse } from "fetch-mock";
20+
import FetchMock from "fetch-mock";
2121
import fetchMock from "fetch-mock-jest";
2222
import { IDBFactory } from "fake-indexeddb";
2323
import { createHash } from "crypto";
@@ -1511,7 +1511,7 @@ function expectSendToDeviceMessage(msgtype: string): Promise<{ messages: any }>
15111511
return new Promise((resolve) => {
15121512
fetchMock.putOnce(
15131513
new RegExp(`/_matrix/client/(r0|v3)/sendToDevice/${escapeRegExp(msgtype)}`),
1514-
(url: string, opts: RequestInit): MockResponse => {
1514+
(url: string, opts: RequestInit): FetchMock.MockResponse => {
15151515
resolve(JSON.parse(opts.body as string));
15161516
return {};
15171517
},
@@ -1535,7 +1535,7 @@ function mockSecretRequestAndGetPromises(): Map<string, Promise<string>> {
15351535

15361536
fetchMock.put(
15371537
new RegExp(`/_matrix/client/(r0|v3)/sendToDevice/m.secret.request`),
1538-
(url: string, opts: RequestInit): MockResponse => {
1538+
(url: string, opts: RequestInit): FetchMock.MockResponse => {
15391539
const messages = JSON.parse(opts.body as string).messages[TEST_USER_ID];
15401540
// rust crypto broadcasts to all devices, old crypto to a specific device, take the first one
15411541
const content = Object.values(messages)[0] as any;

spec/test-utils/AccountDataAccumulator.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ limitations under the License.
1515
*/
1616

1717
import fetchMock from "fetch-mock-jest";
18-
import { MockOptionsMethodPut } from "fetch-mock";
1918

2019
import { ISyncResponder } from "./SyncResponder";
2120

@@ -40,7 +39,10 @@ export class AccountDataAccumulator {
4039
* @param opts - options to pass to fetchMock
4140
* @returns a Promise which will resolve (with the content of the account data) once it is set.
4241
*/
43-
public interceptSetAccountData(accountDataType: string, opts?: MockOptionsMethodPut): Promise<any> {
42+
public interceptSetAccountData(
43+
accountDataType: string,
44+
opts?: Parameters<(typeof fetchMock)["put"]>[2],
45+
): Promise<any> {
4446
return new Promise((resolve) => {
4547
// Called when the cross signing key is uploaded
4648
fetchMock.put(

spec/test-utils/SyncResponder.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ limitations under the License.
1717
import debugFunc from "debug";
1818
import { Debugger } from "debug";
1919
import fetchMock from "fetch-mock-jest";
20-
import { MockResponse } from "fetch-mock";
20+
import FetchMock from "fetch-mock";
2121

2222
/** Interface implemented by classes that intercept `/sync` requests from test clients
2323
*
@@ -80,7 +80,7 @@ export class SyncResponder implements ISyncResponder {
8080
);
8181
}
8282

83-
private async onSyncRequest(): Promise<MockResponse> {
83+
private async onSyncRequest(): Promise<FetchMock.MockResponse> {
8484
switch (this.state) {
8585
case SyncResponderState.IDLE: {
8686
this.debug("Got /sync request: waiting for response to be ready");

yarn.lock

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3663,7 +3663,19 @@ fetch-mock-jest@^1.5.1:
36633663
dependencies:
36643664
fetch-mock "^9.11.0"
36653665

3666-
fetch-mock@9.11.0, fetch-mock@^9.11.0:
3666+
fetch-mock@10.0.7:
3667+
version "10.0.7"
3668+
resolved "https://registry.yarnpkg.com/fetch-mock/-/fetch-mock-10.0.7.tgz#b274aaebe5b59c641f02d836b579bbe9b063f8db"
3669+
integrity sha512-TFG42kMRJ6dZpUDeVTdXNjh5O4TchHU/UNk41a050TwKzRr5RJQbtckXDjXiQFHPKgXGUG5l2TY3ZZ2gokiXaQ==
3670+
dependencies:
3671+
debug "^4.1.1"
3672+
glob-to-regexp "^0.4.0"
3673+
is-subset "^0.1.1"
3674+
lodash.isequal "^4.5.0"
3675+
path-to-regexp "^2.2.1"
3676+
querystring "^0.2.1"
3677+
3678+
fetch-mock@^9.11.0:
36673679
version "9.11.0"
36683680
resolved "https://registry.yarnpkg.com/fetch-mock/-/fetch-mock-9.11.0.tgz#371c6fb7d45584d2ae4a18ee6824e7ad4b637a3f"
36693681
integrity sha512-PG1XUv+x7iag5p/iNHD4/jdpxL9FtVSqRMUQhPab4hVDt80T1MH5ehzVrL2IdXO9Q2iBggArFvPqjUbHFuI58Q==
@@ -5680,7 +5692,7 @@ pvutils@^1.1.3:
56805692
resolved "https://registry.yarnpkg.com/pvutils/-/pvutils-1.1.3.tgz#f35fc1d27e7cd3dfbd39c0826d173e806a03f5a3"
56815693
integrity sha512-pMpnA0qRdFp32b1sJl1wOJNxZLQ2cbQx+k6tjNtZ8CpvVhNqEPRgivZ2WOUev2YMajecdH7ctUPDvEe87nariQ==
56825694

5683-
querystring@^0.2.0:
5695+
querystring@^0.2.0, querystring@^0.2.1:
56845696
version "0.2.1"
56855697
resolved "https://registry.yarnpkg.com/querystring/-/querystring-0.2.1.tgz#40d77615bb09d16902a85c3e38aa8b5ed761c2dd"
56865698
integrity sha512-wkvS7mL/JMugcup3/rMitHmd9ecIGd2lhFhK9N3UUQ450h66d1r3Y9nvXzQAW1Lq+wyx61k/1pfKS5KuKiyEbg==

0 commit comments

Comments
 (0)