Make more code conform to strict null checks (#10219
* Make more code conform to strict null checks * Fix types * Fix tests * Fix remaining test assertions * Iterate PR
This commit is contained in:
parent
4c79ecf141
commit
76b82b4b2b
130 changed files with 603 additions and 603 deletions
|
@ -185,7 +185,6 @@ describe("RovingTabIndex", () => {
|
|||
const ref4 = React.createRef<HTMLElement>();
|
||||
|
||||
let state: IState = {
|
||||
activeRef: null,
|
||||
refs: [ref1, ref2, ref3, ref4],
|
||||
};
|
||||
|
||||
|
@ -196,7 +195,6 @@ describe("RovingTabIndex", () => {
|
|||
},
|
||||
});
|
||||
expect(state).toStrictEqual({
|
||||
activeRef: null,
|
||||
refs: [ref1, ref3, ref4],
|
||||
});
|
||||
|
||||
|
@ -207,7 +205,6 @@ describe("RovingTabIndex", () => {
|
|||
},
|
||||
});
|
||||
expect(state).toStrictEqual({
|
||||
activeRef: null,
|
||||
refs: [ref1, ref4],
|
||||
});
|
||||
|
||||
|
@ -218,7 +215,6 @@ describe("RovingTabIndex", () => {
|
|||
},
|
||||
});
|
||||
expect(state).toStrictEqual({
|
||||
activeRef: null,
|
||||
refs: [ref1],
|
||||
});
|
||||
|
||||
|
@ -229,7 +225,6 @@ describe("RovingTabIndex", () => {
|
|||
},
|
||||
});
|
||||
expect(state).toStrictEqual({
|
||||
activeRef: null,
|
||||
refs: [],
|
||||
});
|
||||
});
|
||||
|
@ -250,7 +245,6 @@ describe("RovingTabIndex", () => {
|
|||
);
|
||||
|
||||
let state: IState = {
|
||||
activeRef: null,
|
||||
refs: [],
|
||||
};
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
exports[`<EmbeddedPage /> should render nothing if no url given 1`] = `
|
||||
<DocumentFragment>
|
||||
<div
|
||||
class="undefined undefined_guest"
|
||||
class="undefined_guest"
|
||||
>
|
||||
<div
|
||||
class="undefined_body"
|
||||
|
@ -15,7 +15,7 @@ exports[`<EmbeddedPage /> should render nothing if no url given 1`] = `
|
|||
exports[`<EmbeddedPage /> should show error if unable to load 1`] = `
|
||||
<DocumentFragment>
|
||||
<div
|
||||
class="undefined undefined_guest"
|
||||
class="undefined_guest"
|
||||
>
|
||||
<div
|
||||
class="undefined_body"
|
||||
|
@ -29,7 +29,7 @@ exports[`<EmbeddedPage /> should show error if unable to load 1`] = `
|
|||
exports[`<EmbeddedPage /> should translate _t strings 1`] = `
|
||||
<DocumentFragment>
|
||||
<div
|
||||
class="undefined undefined_guest"
|
||||
class="undefined_guest"
|
||||
>
|
||||
<div
|
||||
class="undefined_body"
|
||||
|
|
|
@ -39,7 +39,7 @@ describe("InteractiveAuthDialog", function () {
|
|||
|
||||
beforeEach(function () {
|
||||
jest.clearAllMocks();
|
||||
mockClient.credentials = null;
|
||||
mockClient.credentials = { userId: null };
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
|
|
|
@ -97,7 +97,7 @@ function mockClient({
|
|||
);
|
||||
return Promise.resolve({
|
||||
results: results.slice(0, limit ?? +Infinity),
|
||||
limited: limit && limit < results.length,
|
||||
limited: !!limit && limit < results.length,
|
||||
});
|
||||
});
|
||||
cli.getProfileInfo = jest.fn(async (userId) => {
|
||||
|
|
|
@ -74,8 +74,8 @@ describe("<UserSettingsDialog />", () => {
|
|||
});
|
||||
|
||||
const getActiveTabLabel = (container: Element) =>
|
||||
container.querySelector(".mx_TabbedView_tabLabel_active").textContent;
|
||||
const getActiveTabHeading = (container: Element) => container.querySelector(".mx_SettingsTab_heading").textContent;
|
||||
container.querySelector(".mx_TabbedView_tabLabel_active")?.textContent;
|
||||
const getActiveTabHeading = (container: Element) => container.querySelector(".mx_SettingsTab_heading")?.textContent;
|
||||
|
||||
it("should render general settings tab when no initialTabId", () => {
|
||||
const { container } = render(getComponent());
|
||||
|
|
|
@ -146,7 +146,7 @@ describe("<LocationShareMenu />", () => {
|
|||
const setLocationGeolocate = () => {
|
||||
// get the callback LocationShareMenu registered for geolocate
|
||||
expect(mocked(mockGeolocate.on)).toHaveBeenCalledWith("geolocate", expect.any(Function));
|
||||
const [, onGeolocateCallback] = mocked(mockGeolocate.on).mock.calls.find(([event]) => event === "geolocate");
|
||||
const [, onGeolocateCallback] = mocked(mockGeolocate.on).mock.calls.find(([event]) => event === "geolocate")!;
|
||||
|
||||
// set the location
|
||||
onGeolocateCallback(position);
|
||||
|
@ -155,7 +155,7 @@ describe("<LocationShareMenu />", () => {
|
|||
const setLocationClick = () => {
|
||||
// get the callback LocationShareMenu registered for geolocate
|
||||
expect(mocked(mockMap.on)).toHaveBeenCalledWith("click", expect.any(Function));
|
||||
const [, onMapClickCallback] = mocked(mockMap.on).mock.calls.find(([event]) => event === "click");
|
||||
const [, onMapClickCallback] = mocked(mockMap.on).mock.calls.find(([event]) => event === "click")!;
|
||||
|
||||
const event = {
|
||||
lngLat: { lng: position.coords.longitude, lat: position.coords.latitude },
|
||||
|
|
|
@ -51,6 +51,6 @@ describe("<LocationViewDialog />", () => {
|
|||
// @ts-ignore cheat assignment to property
|
||||
selfShareEvent.sender = member;
|
||||
const { container } = getComponent({ mxEvent: selfShareEvent });
|
||||
expect(container.querySelector(".mx_BaseAvatar_image").getAttribute("title")).toEqual(userId);
|
||||
expect(container.querySelector(".mx_BaseAvatar_image")?.getAttribute("title")).toEqual(userId);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -28,7 +28,7 @@ describe("ReadReceiptGroup", () => {
|
|||
expect(readReceiptTooltip(["Alice", "Bob", "Charlie"], true)).toEqual("Alice, Bob, Charlie and more");
|
||||
expect(readReceiptTooltip(["Alice", "Bob"], true)).toEqual("Alice, Bob and more");
|
||||
expect(readReceiptTooltip(["Alice"], true)).toEqual("Alice and more");
|
||||
expect(readReceiptTooltip([], false)).toEqual(null);
|
||||
expect(readReceiptTooltip([], false)).toBeUndefined();
|
||||
});
|
||||
it("returns a pretty list without hasMore", () => {
|
||||
expect(readReceiptTooltip(["Alice", "Bob", "Charlie", "Dan", "Eve"], false)).toEqual(
|
||||
|
@ -40,7 +40,7 @@ describe("ReadReceiptGroup", () => {
|
|||
expect(readReceiptTooltip(["Alice", "Bob", "Charlie"], false)).toEqual("Alice, Bob and Charlie");
|
||||
expect(readReceiptTooltip(["Alice", "Bob"], false)).toEqual("Alice and Bob");
|
||||
expect(readReceiptTooltip(["Alice"], false)).toEqual("Alice");
|
||||
expect(readReceiptTooltip([], false)).toEqual(null);
|
||||
expect(readReceiptTooltip([], false)).toBeUndefined();
|
||||
});
|
||||
});
|
||||
describe("AvatarPosition", () => {
|
||||
|
|
|
@ -281,7 +281,7 @@ describe("<SendMessageComposer/>", () => {
|
|||
|
||||
it("correctly sends a message", () => {
|
||||
mocked(doMaybeLocalRoomAction).mockImplementation(
|
||||
<T extends {}>(roomId: string, fn: (actualRoomId: string) => Promise<T>, _client?: MatrixClient) => {
|
||||
<T,>(roomId: string, fn: (actualRoomId: string) => Promise<T>, _client?: MatrixClient) => {
|
||||
return fn(roomId);
|
||||
},
|
||||
);
|
||||
|
@ -300,7 +300,7 @@ describe("<SendMessageComposer/>", () => {
|
|||
|
||||
it("shows chat effects on message sending", () => {
|
||||
mocked(doMaybeLocalRoomAction).mockImplementation(
|
||||
<T extends {}>(roomId: string, fn: (actualRoomId: string) => Promise<T>, _client?: MatrixClient) => {
|
||||
<T,>(roomId: string, fn: (actualRoomId: string) => Promise<T>, _client?: MatrixClient) => {
|
||||
return fn(roomId);
|
||||
},
|
||||
);
|
||||
|
@ -321,7 +321,7 @@ describe("<SendMessageComposer/>", () => {
|
|||
|
||||
it("not to send chat effects on message sending for threads", () => {
|
||||
mocked(doMaybeLocalRoomAction).mockImplementation(
|
||||
<T extends {}>(roomId: string, fn: (actualRoomId: string) => Promise<T>, _client?: MatrixClient) => {
|
||||
<T,>(roomId: string, fn: (actualRoomId: string) => Promise<T>, _client?: MatrixClient) => {
|
||||
return fn(roomId);
|
||||
},
|
||||
);
|
||||
|
|
|
@ -25,6 +25,7 @@ import { VoiceRecording } from "../../../../src/audio/VoiceRecording";
|
|||
import { doMaybeLocalRoomAction } from "../../../../src/utils/local-room";
|
||||
import { MatrixClientPeg } from "../../../../src/MatrixClientPeg";
|
||||
import { IUpload } from "../../../../src/audio/VoiceMessageRecording";
|
||||
import { RoomPermalinkCreator } from "../../../../src/utils/permalinks/Permalinks";
|
||||
|
||||
jest.mock("../../../../src/utils/local-room", () => ({
|
||||
doMaybeLocalRoomAction: jest.fn(),
|
||||
|
@ -43,10 +44,12 @@ describe("<VoiceRecordComposerTile/>", () => {
|
|||
} as unknown as MatrixClient;
|
||||
MatrixClientPeg.get = () => mockClient;
|
||||
|
||||
const room = {
|
||||
roomId,
|
||||
} as unknown as Room;
|
||||
const props = {
|
||||
room: {
|
||||
roomId,
|
||||
} as unknown as Room,
|
||||
room,
|
||||
permalinkCreator: new RoomPermalinkCreator(room),
|
||||
};
|
||||
mockUpload = {
|
||||
mxc: "mxc://example.com/voice",
|
||||
|
@ -66,7 +69,7 @@ describe("<VoiceRecordComposerTile/>", () => {
|
|||
});
|
||||
|
||||
mocked(doMaybeLocalRoomAction).mockImplementation(
|
||||
<T extends {}>(roomId: string, fn: (actualRoomId: string) => Promise<T>, _client?: MatrixClient) => {
|
||||
<T,>(roomId: string, fn: (actualRoomId: string) => Promise<T>, _client?: MatrixClient) => {
|
||||
return fn(roomId);
|
||||
},
|
||||
);
|
||||
|
|
|
@ -42,6 +42,7 @@ describe("<CurrentDeviceSection />", () => {
|
|||
isLoading: false,
|
||||
isSigningOut: false,
|
||||
otherSessionsCount: 1,
|
||||
setPushNotifications: jest.fn(),
|
||||
};
|
||||
|
||||
const getComponent = (props = {}): React.ReactElement => <CurrentDeviceSection {...defaultProps} {...props} />;
|
||||
|
|
|
@ -47,7 +47,7 @@ describe("AdvancedRoomSettingsTab", () => {
|
|||
mocked(dis.dispatch).mockReset();
|
||||
mocked(room.findPredecessor).mockImplementation((msc3946: boolean) =>
|
||||
msc3946
|
||||
? { roomId: "old_room_id_via_predecessor", eventId: null }
|
||||
? { roomId: "old_room_id_via_predecessor" }
|
||||
: { roomId: "old_room_id", eventId: "tombstone_event_id" },
|
||||
);
|
||||
});
|
||||
|
@ -136,7 +136,7 @@ describe("AdvancedRoomSettingsTab", () => {
|
|||
fireEvent.click(link);
|
||||
expect(dis.dispatch).toHaveBeenCalledWith({
|
||||
action: Action.ViewRoom,
|
||||
event_id: null,
|
||||
event_id: undefined,
|
||||
room_id: "old_room_id_via_predecessor",
|
||||
metricsTrigger: "WebPredecessorSettings",
|
||||
metricsViaKeyboard: false,
|
||||
|
|
|
@ -78,22 +78,16 @@ describe("createRoom", () => {
|
|||
const createCallSpy = jest.spyOn(ElementCall, "create");
|
||||
const roomId = await createRoom({ roomType: RoomType.UnstableCall });
|
||||
|
||||
const [
|
||||
[
|
||||
{
|
||||
power_level_content_override: {
|
||||
users: { [userId]: userPower },
|
||||
events: {
|
||||
[ElementCall.CALL_EVENT_TYPE.name]: callPower,
|
||||
[ElementCall.MEMBER_EVENT_TYPE.name]: callMemberPower,
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
] = client.createRoom.mock.calls;
|
||||
const userPower = client.createRoom.mock.calls[0][0].power_level_content_override?.users?.[userId];
|
||||
const callPower =
|
||||
client.createRoom.mock.calls[0][0].power_level_content_override?.events?.[ElementCall.CALL_EVENT_TYPE.name];
|
||||
const callMemberPower =
|
||||
client.createRoom.mock.calls[0][0].power_level_content_override?.events?.[
|
||||
ElementCall.MEMBER_EVENT_TYPE.name
|
||||
];
|
||||
|
||||
// We should have had enough power to be able to set up the call
|
||||
expect(userPower).toBeGreaterThanOrEqual(callPower);
|
||||
expect(userPower).toBeGreaterThanOrEqual(callPower!);
|
||||
// and should have actually set it up
|
||||
expect(createCallSpy).toHaveBeenCalled();
|
||||
|
||||
|
@ -122,18 +116,12 @@ describe("createRoom", () => {
|
|||
|
||||
await createRoom({});
|
||||
|
||||
const [
|
||||
[
|
||||
{
|
||||
power_level_content_override: {
|
||||
events: {
|
||||
[ElementCall.CALL_EVENT_TYPE.name]: callPower,
|
||||
[ElementCall.MEMBER_EVENT_TYPE.name]: callMemberPower,
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
] = client.createRoom.mock.calls;
|
||||
const callPower =
|
||||
client.createRoom.mock.calls[0][0].power_level_content_override?.events?.[ElementCall.CALL_EVENT_TYPE.name];
|
||||
const callMemberPower =
|
||||
client.createRoom.mock.calls[0][0].power_level_content_override?.events?.[
|
||||
ElementCall.MEMBER_EVENT_TYPE.name
|
||||
];
|
||||
|
||||
expect(callPower).toBe(100);
|
||||
expect(callMemberPower).toBe(100);
|
||||
|
|
|
@ -35,9 +35,9 @@ describe("parseGeoUri", () => {
|
|||
longitude: 16.3695,
|
||||
altitude: 183,
|
||||
accuracy: undefined,
|
||||
altitudeAccuracy: undefined,
|
||||
heading: undefined,
|
||||
speed: undefined,
|
||||
altitudeAccuracy: null,
|
||||
heading: null,
|
||||
speed: null,
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -45,11 +45,11 @@ describe("parseGeoUri", () => {
|
|||
expect(parseGeoUri("geo:48.198634,16.371648;crs=wgs84;u=40")).toEqual({
|
||||
latitude: 48.198634,
|
||||
longitude: 16.371648,
|
||||
altitude: undefined,
|
||||
altitude: null,
|
||||
accuracy: 40,
|
||||
altitudeAccuracy: undefined,
|
||||
heading: undefined,
|
||||
speed: undefined,
|
||||
altitudeAccuracy: null,
|
||||
heading: null,
|
||||
speed: null,
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -57,11 +57,11 @@ describe("parseGeoUri", () => {
|
|||
expect(parseGeoUri("geo:90,-22.43;crs=WGS84")).toEqual({
|
||||
latitude: 90,
|
||||
longitude: -22.43,
|
||||
altitude: undefined,
|
||||
altitude: null,
|
||||
accuracy: undefined,
|
||||
altitudeAccuracy: undefined,
|
||||
heading: undefined,
|
||||
speed: undefined,
|
||||
altitudeAccuracy: null,
|
||||
heading: null,
|
||||
speed: null,
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -69,11 +69,11 @@ describe("parseGeoUri", () => {
|
|||
expect(parseGeoUri("geo:90,46")).toEqual({
|
||||
latitude: 90,
|
||||
longitude: 46,
|
||||
altitude: undefined,
|
||||
altitude: null,
|
||||
accuracy: undefined,
|
||||
altitudeAccuracy: undefined,
|
||||
heading: undefined,
|
||||
speed: undefined,
|
||||
altitudeAccuracy: null,
|
||||
heading: null,
|
||||
speed: null,
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -81,11 +81,11 @@ describe("parseGeoUri", () => {
|
|||
expect(parseGeoUri("geo:66,30;u=6.500;FOo=this%2dthat")).toEqual({
|
||||
latitude: 66,
|
||||
longitude: 30,
|
||||
altitude: undefined,
|
||||
altitude: null,
|
||||
accuracy: 6.5,
|
||||
altitudeAccuracy: undefined,
|
||||
heading: undefined,
|
||||
speed: undefined,
|
||||
altitudeAccuracy: null,
|
||||
heading: null,
|
||||
speed: null,
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -93,11 +93,11 @@ describe("parseGeoUri", () => {
|
|||
expect(parseGeoUri("geo:66.0,30;u=6.5;foo=this-that>")).toEqual({
|
||||
latitude: 66.0,
|
||||
longitude: 30,
|
||||
altitude: undefined,
|
||||
altitude: null,
|
||||
accuracy: 6.5,
|
||||
altitudeAccuracy: undefined,
|
||||
heading: undefined,
|
||||
speed: undefined,
|
||||
altitudeAccuracy: null,
|
||||
heading: null,
|
||||
speed: null,
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -105,11 +105,11 @@ describe("parseGeoUri", () => {
|
|||
expect(parseGeoUri("geo:70,20;foo=1.00;bar=white")).toEqual({
|
||||
latitude: 70,
|
||||
longitude: 20,
|
||||
altitude: undefined,
|
||||
altitude: null,
|
||||
accuracy: undefined,
|
||||
altitudeAccuracy: undefined,
|
||||
heading: undefined,
|
||||
speed: undefined,
|
||||
altitudeAccuracy: null,
|
||||
heading: null,
|
||||
speed: null,
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -117,11 +117,11 @@ describe("parseGeoUri", () => {
|
|||
expect(parseGeoUri("geo:-7.5,20")).toEqual({
|
||||
latitude: -7.5,
|
||||
longitude: 20,
|
||||
altitude: undefined,
|
||||
altitude: null,
|
||||
accuracy: undefined,
|
||||
altitudeAccuracy: undefined,
|
||||
heading: undefined,
|
||||
speed: undefined,
|
||||
altitudeAccuracy: null,
|
||||
heading: null,
|
||||
speed: null,
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -131,9 +131,9 @@ describe("parseGeoUri", () => {
|
|||
longitude: -20,
|
||||
altitude: 0,
|
||||
accuracy: undefined,
|
||||
altitudeAccuracy: undefined,
|
||||
heading: undefined,
|
||||
speed: undefined,
|
||||
altitudeAccuracy: null,
|
||||
heading: null,
|
||||
speed: null,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -91,7 +91,7 @@ describe("Permalinks", function () {
|
|||
const creator = new RoomPermalinkCreator(room);
|
||||
creator.load();
|
||||
expect(creator.serverCandidates).toBeTruthy();
|
||||
expect(creator.serverCandidates.length).toBe(0);
|
||||
expect(creator.serverCandidates!.length).toBe(0);
|
||||
});
|
||||
|
||||
it("should gracefully handle invalid MXIDs", () => {
|
||||
|
@ -112,8 +112,8 @@ describe("Permalinks", function () {
|
|||
const creator = new RoomPermalinkCreator(room);
|
||||
creator.load();
|
||||
expect(creator.serverCandidates).toBeTruthy();
|
||||
expect(creator.serverCandidates.length).toBe(3);
|
||||
expect(creator.serverCandidates[0]).toBe("pl_95");
|
||||
expect(creator.serverCandidates!.length).toBe(3);
|
||||
expect(creator.serverCandidates![0]).toBe("pl_95");
|
||||
// we don't check the 2nd and 3rd servers because that is done by the next test
|
||||
});
|
||||
|
||||
|
@ -128,15 +128,15 @@ describe("Permalinks", function () {
|
|||
]);
|
||||
const creator = new RoomPermalinkCreator(room, null);
|
||||
creator.load();
|
||||
expect(creator.serverCandidates[0]).toBe("pl_95");
|
||||
expect(creator.serverCandidates![0]).toBe("pl_95");
|
||||
member95.membership = "left";
|
||||
// @ts-ignore illegal private property
|
||||
creator.onRoomStateUpdate();
|
||||
expect(creator.serverCandidates[0]).toBe("pl_75");
|
||||
expect(creator.serverCandidates![0]).toBe("pl_75");
|
||||
member95.membership = "join";
|
||||
// @ts-ignore illegal private property
|
||||
creator.onRoomStateUpdate();
|
||||
expect(creator.serverCandidates[0]).toBe("pl_95");
|
||||
expect(creator.serverCandidates![0]).toBe("pl_95");
|
||||
});
|
||||
|
||||
it("should pick candidate servers based on user population", function () {
|
||||
|
@ -152,10 +152,10 @@ describe("Permalinks", function () {
|
|||
const creator = new RoomPermalinkCreator(room);
|
||||
creator.load();
|
||||
expect(creator.serverCandidates).toBeTruthy();
|
||||
expect(creator.serverCandidates.length).toBe(3);
|
||||
expect(creator.serverCandidates[0]).toBe("first");
|
||||
expect(creator.serverCandidates[1]).toBe("second");
|
||||
expect(creator.serverCandidates[2]).toBe("third");
|
||||
expect(creator.serverCandidates!.length).toBe(3);
|
||||
expect(creator.serverCandidates![0]).toBe("first");
|
||||
expect(creator.serverCandidates![1]).toBe("second");
|
||||
expect(creator.serverCandidates![2]).toBe("third");
|
||||
});
|
||||
|
||||
it("should pick prefer candidate servers with higher power levels", function () {
|
||||
|
@ -168,10 +168,10 @@ describe("Permalinks", function () {
|
|||
]);
|
||||
const creator = new RoomPermalinkCreator(room);
|
||||
creator.load();
|
||||
expect(creator.serverCandidates.length).toBe(3);
|
||||
expect(creator.serverCandidates[0]).toBe("first");
|
||||
expect(creator.serverCandidates[1]).toBe("second");
|
||||
expect(creator.serverCandidates[2]).toBe("third");
|
||||
expect(creator.serverCandidates!.length).toBe(3);
|
||||
expect(creator.serverCandidates![0]).toBe("first");
|
||||
expect(creator.serverCandidates![1]).toBe("second");
|
||||
expect(creator.serverCandidates![2]).toBe("third");
|
||||
});
|
||||
|
||||
it("should pick a maximum of 3 candidate servers", function () {
|
||||
|
@ -186,7 +186,7 @@ describe("Permalinks", function () {
|
|||
const creator = new RoomPermalinkCreator(room);
|
||||
creator.load();
|
||||
expect(creator.serverCandidates).toBeTruthy();
|
||||
expect(creator.serverCandidates.length).toBe(3);
|
||||
expect(creator.serverCandidates!.length).toBe(3);
|
||||
});
|
||||
|
||||
it("should not consider IPv4 hosts", function () {
|
||||
|
@ -195,7 +195,7 @@ describe("Permalinks", function () {
|
|||
const creator = new RoomPermalinkCreator(room);
|
||||
creator.load();
|
||||
expect(creator.serverCandidates).toBeTruthy();
|
||||
expect(creator.serverCandidates.length).toBe(0);
|
||||
expect(creator.serverCandidates!.length).toBe(0);
|
||||
});
|
||||
|
||||
it("should not consider IPv6 hosts", function () {
|
||||
|
@ -204,7 +204,7 @@ describe("Permalinks", function () {
|
|||
const creator = new RoomPermalinkCreator(room);
|
||||
creator.load();
|
||||
expect(creator.serverCandidates).toBeTruthy();
|
||||
expect(creator.serverCandidates.length).toBe(0);
|
||||
expect(creator.serverCandidates!.length).toBe(0);
|
||||
});
|
||||
|
||||
it("should not consider IPv4 hostnames with ports", function () {
|
||||
|
@ -213,7 +213,7 @@ describe("Permalinks", function () {
|
|||
const creator = new RoomPermalinkCreator(room);
|
||||
creator.load();
|
||||
expect(creator.serverCandidates).toBeTruthy();
|
||||
expect(creator.serverCandidates.length).toBe(0);
|
||||
expect(creator.serverCandidates!.length).toBe(0);
|
||||
});
|
||||
|
||||
it("should not consider IPv6 hostnames with ports", function () {
|
||||
|
@ -222,7 +222,7 @@ describe("Permalinks", function () {
|
|||
const creator = new RoomPermalinkCreator(room);
|
||||
creator.load();
|
||||
expect(creator.serverCandidates).toBeTruthy();
|
||||
expect(creator.serverCandidates.length).toBe(0);
|
||||
expect(creator.serverCandidates!.length).toBe(0);
|
||||
});
|
||||
|
||||
it("should work with hostnames with ports", function () {
|
||||
|
@ -232,8 +232,8 @@ describe("Permalinks", function () {
|
|||
const creator = new RoomPermalinkCreator(room);
|
||||
creator.load();
|
||||
expect(creator.serverCandidates).toBeTruthy();
|
||||
expect(creator.serverCandidates.length).toBe(1);
|
||||
expect(creator.serverCandidates[0]).toBe("example.org:8448");
|
||||
expect(creator.serverCandidates!.length).toBe(1);
|
||||
expect(creator.serverCandidates![0]).toBe("example.org:8448");
|
||||
});
|
||||
|
||||
it("should not consider servers explicitly denied by ACLs", function () {
|
||||
|
@ -252,7 +252,7 @@ describe("Permalinks", function () {
|
|||
const creator = new RoomPermalinkCreator(room);
|
||||
creator.load();
|
||||
expect(creator.serverCandidates).toBeTruthy();
|
||||
expect(creator.serverCandidates.length).toBe(0);
|
||||
expect(creator.serverCandidates!.length).toBe(0);
|
||||
});
|
||||
|
||||
it("should not consider servers not allowed by ACLs", function () {
|
||||
|
@ -271,7 +271,7 @@ describe("Permalinks", function () {
|
|||
const creator = new RoomPermalinkCreator(room);
|
||||
creator.load();
|
||||
expect(creator.serverCandidates).toBeTruthy();
|
||||
expect(creator.serverCandidates.length).toBe(0);
|
||||
expect(creator.serverCandidates!.length).toBe(0);
|
||||
});
|
||||
|
||||
it("should consider servers not explicitly banned by ACLs", function () {
|
||||
|
@ -290,8 +290,8 @@ describe("Permalinks", function () {
|
|||
const creator = new RoomPermalinkCreator(room);
|
||||
creator.load();
|
||||
expect(creator.serverCandidates).toBeTruthy();
|
||||
expect(creator.serverCandidates.length).toBe(1);
|
||||
expect(creator.serverCandidates[0]).toEqual("evilcorp.com");
|
||||
expect(creator.serverCandidates!.length).toBe(1);
|
||||
expect(creator.serverCandidates![0]).toEqual("evilcorp.com");
|
||||
});
|
||||
|
||||
it("should consider servers not disallowed by ACLs", function () {
|
||||
|
@ -310,8 +310,8 @@ describe("Permalinks", function () {
|
|||
const creator = new RoomPermalinkCreator(room);
|
||||
creator.load();
|
||||
expect(creator.serverCandidates).toBeTruthy();
|
||||
expect(creator.serverCandidates.length).toBe(1);
|
||||
expect(creator.serverCandidates[0]).toEqual("evilcorp.com");
|
||||
expect(creator.serverCandidates!.length).toBe(1);
|
||||
expect(creator.serverCandidates![0]).toEqual("evilcorp.com");
|
||||
});
|
||||
|
||||
it("should generate an event permalink for room IDs with no candidate servers", function () {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue