2022-11-22 18:05:09 +03:00
|
|
|
/*
|
2024-09-09 16:57:16 +03:00
|
|
|
Copyright 2024 New Vector Ltd.
|
2022-11-22 18:05:09 +03:00
|
|
|
Copyright 2022 The Matrix.org Foundation C.I.C.
|
|
|
|
|
2024-09-09 16:57:16 +03:00
|
|
|
SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only
|
|
|
|
Please see LICENSE files in the repository root for full details.
|
2022-11-22 18:05:09 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
import React from "react";
|
2024-10-14 19:11:58 +03:00
|
|
|
import { render } from "jest-matrix-react";
|
2023-08-09 10:18:41 +03:00
|
|
|
import { IPublicRoomsChunkRoom } from "matrix-js-sdk/src/matrix";
|
2022-11-22 18:05:09 +03:00
|
|
|
|
|
|
|
import { PublicRoomResultDetails } from "../../../../../src/components/views/dialogs/spotlight/PublicRoomResultDetails";
|
|
|
|
|
|
|
|
describe("PublicRoomResultDetails", () => {
|
|
|
|
it("renders", () => {
|
2022-12-12 14:24:14 +03:00
|
|
|
const { asFragment } = render(
|
|
|
|
<PublicRoomResultDetails
|
|
|
|
room={{
|
|
|
|
room_id: "room-id",
|
|
|
|
name: "hello?",
|
|
|
|
canonical_alias: "canonical-alias",
|
|
|
|
world_readable: true,
|
|
|
|
guest_can_join: false,
|
|
|
|
num_joined_members: 666,
|
|
|
|
}}
|
|
|
|
labelId="label-id"
|
|
|
|
descriptionId="description-id"
|
|
|
|
detailsId="details-id"
|
|
|
|
/>,
|
|
|
|
);
|
2022-11-22 18:05:09 +03:00
|
|
|
|
|
|
|
expect(asFragment()).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
|
|
|
|
it.each([
|
|
|
|
{ canonical_alias: "canonical-alias" },
|
|
|
|
{ aliases: ["alias-from-aliases"] },
|
|
|
|
{ name: "name over alias", canonical_alias: "canonical-alias" },
|
|
|
|
{
|
|
|
|
name: "with an overly long name that will be truncated for sure, you can't say anything about it",
|
|
|
|
topic: "with a topic!",
|
|
|
|
},
|
|
|
|
{ topic: "Very long topic " + new Array(1337).join("a") },
|
|
|
|
])("Public room results", (partialPublicRoomChunk: Partial<IPublicRoomsChunkRoom>) => {
|
|
|
|
const roomChunk: IPublicRoomsChunkRoom = {
|
|
|
|
room_id: "room-id",
|
|
|
|
world_readable: true,
|
|
|
|
guest_can_join: false,
|
|
|
|
num_joined_members: 666,
|
|
|
|
...partialPublicRoomChunk,
|
|
|
|
};
|
|
|
|
|
2022-12-12 14:24:14 +03:00
|
|
|
const { asFragment } = render(
|
|
|
|
<PublicRoomResultDetails
|
|
|
|
room={roomChunk}
|
|
|
|
labelId="label-id"
|
|
|
|
descriptionId="description-id"
|
|
|
|
detailsId="details-id"
|
|
|
|
/>,
|
|
|
|
);
|
2022-11-22 18:05:09 +03:00
|
|
|
|
|
|
|
expect(asFragment()).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
});
|