mirror of
https://github.com/vector-im/element-call.git
synced 2026-07-27 19:29:19 +00:00
fixup test: Errors are now wrapped in user readable error
and proper fetchmock for doNetworkOperationWithRetry
This commit is contained in:
@@ -19,12 +19,14 @@ import fetchMock from "fetch-mock";
|
|||||||
import { getSFUConfigWithOpenID, type OpenIDClientParts } from "./openIDSFU";
|
import { getSFUConfigWithOpenID, type OpenIDClientParts } from "./openIDSFU";
|
||||||
import { testJWTToken } from "../utils/test-fixtures";
|
import { testJWTToken } from "../utils/test-fixtures";
|
||||||
import { ownMemberMock } from "../utils/test";
|
import { ownMemberMock } from "../utils/test";
|
||||||
|
import { FailToGetOpenIdToken } from "../utils/errors";
|
||||||
|
|
||||||
const sfuUrl = "https://sfu.example.org";
|
const sfuUrl = "https://sfu.example.org";
|
||||||
|
|
||||||
describe("getSFUConfigWithOpenID", () => {
|
describe("getSFUConfigWithOpenID", () => {
|
||||||
let matrixClient: MockedObject<OpenIDClientParts>;
|
let matrixClient: MockedObject<OpenIDClientParts>;
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
fetchMock.catch(404);
|
||||||
matrixClient = {
|
matrixClient = {
|
||||||
getOpenIdToken: vitest.fn(),
|
getOpenIdToken: vitest.fn(),
|
||||||
getDeviceId: vitest.fn(),
|
getDeviceId: vitest.fn(),
|
||||||
@@ -71,9 +73,10 @@ describe("getSFUConfigWithOpenID", () => {
|
|||||||
"https://sfu.example.org",
|
"https://sfu.example.org",
|
||||||
"!example_room_id",
|
"!example_room_id",
|
||||||
);
|
);
|
||||||
} catch (ex) {
|
} catch (ex: unknown) {
|
||||||
expect((ex as Error).message).toEqual(
|
expect(ex).toBeInstanceOf(FailToGetOpenIdToken);
|
||||||
"SFU Config fetch failed with status code 500",
|
expect((ex as FailToGetOpenIdToken).cause).toEqual(
|
||||||
|
new Error("SFU Config fetch failed with status code 500"),
|
||||||
);
|
);
|
||||||
void (await fetchMock.flush());
|
void (await fetchMock.flush());
|
||||||
return;
|
return;
|
||||||
@@ -106,8 +109,9 @@ describe("getSFUConfigWithOpenID", () => {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
} catch (ex) {
|
} catch (ex) {
|
||||||
expect((ex as Error).message).toEqual(
|
expect(ex).toBeInstanceOf(FailToGetOpenIdToken);
|
||||||
"SFU Config fetch failed with status code 500",
|
expect((ex as FailToGetOpenIdToken).cause).toEqual(
|
||||||
|
new Error("SFU Config fetch failed with status code 500"),
|
||||||
);
|
);
|
||||||
void (await fetchMock.flush());
|
void (await fetchMock.flush());
|
||||||
}
|
}
|
||||||
@@ -160,8 +164,9 @@ describe("getSFUConfigWithOpenID", () => {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
} catch (ex) {
|
} catch (ex) {
|
||||||
expect((ex as Error).message).toEqual(
|
expect(ex).toBeInstanceOf(FailToGetOpenIdToken);
|
||||||
"SFU Config fetch failed with status code 500",
|
expect((ex as FailToGetOpenIdToken).cause).toEqual(
|
||||||
|
new Error("SFU Config fetch failed with status code 500"),
|
||||||
);
|
);
|
||||||
void (await fetchMock.flush());
|
void (await fetchMock.flush());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user