2022-11-22 18:05:09 +03:00
|
|
|
/*
|
|
|
|
Copyright 2022 The Matrix.org Foundation C.I.C.
|
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
import React from "react";
|
|
|
|
import { render } from "@testing-library/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();
|
|
|
|
});
|
|
|
|
});
|