1
0
mirror of https://github.com/matrix-org/matrix-react-sdk.git synced 2025-07-31 13:44:28 +03:00

Apply prettier formatting

This commit is contained in:
Michael Weimann
2022-12-12 12:24:14 +01:00
parent 1cac306093
commit 526645c791
1576 changed files with 65385 additions and 62478 deletions

View File

@ -27,18 +27,14 @@ import { stubClient } from "../test-utils/test-utils";
function PublicRoomComponent({ onClick }) {
const roomDirectory = usePublicRoomDirectory();
const {
ready,
loading,
publicRooms,
} = roomDirectory;
const { ready, loading, publicRooms } = roomDirectory;
return <div onClick={() => onClick(roomDirectory)}>
{ (!ready || loading) && `ready: ${ready}, loading: ${loading}` }
{ publicRooms[0] && (
`Name: ${publicRooms[0].name}`
) }
</div>;
return (
<div onClick={() => onClick(roomDirectory)}>
{(!ready || loading) && `ready: ${ready}, loading: ${loading}`}
{publicRooms[0] && `Name: ${publicRooms[0].name}`}
</div>
);
}
describe("usePublicRoomDirectory", () => {
@ -50,27 +46,34 @@ describe("usePublicRoomDirectory", () => {
MatrixClientPeg.getHomeserverName = () => "matrix.org";
cli.getThirdpartyProtocols = () => Promise.resolve({});
cli.publicRooms = (({ filter: { generic_search_term: query } }) => Promise.resolve({
chunk: [{
room_id: "hello world!",
name: query,
world_readable: true,
guest_can_join: true,
num_joined_members: 1,
}],
total_room_count_estimate: 1,
}));
cli.publicRooms = ({ filter: { generic_search_term: query } }) =>
Promise.resolve({
chunk: [
{
room_id: "hello world!",
name: query,
world_readable: true,
guest_can_join: true,
num_joined_members: 1,
},
],
total_room_count_estimate: 1,
});
});
it("should display public rooms when searching", async () => {
const query = "ROOM NAME";
const wrapper = mount(<PublicRoomComponent onClick={(hook) => {
hook.search({
limit: 1,
query,
});
}} />);
const wrapper = mount(
<PublicRoomComponent
onClick={(hook) => {
hook.search({
limit: 1,
query,
});
}}
/>,
);
expect(wrapper.text()).toBe("ready: false, loading: false");
@ -84,12 +87,16 @@ describe("usePublicRoomDirectory", () => {
});
it("should work with empty queries", async () => {
const wrapper = mount(<PublicRoomComponent onClick={(hook) => {
hook.search({
limit: 1,
query: "",
});
}} />);
const wrapper = mount(
<PublicRoomComponent
onClick={(hook) => {
hook.search({
limit: 1,
query: "",
});
}}
/>,
);
await act(async () => {
await sleep(1);
@ -101,15 +108,21 @@ describe("usePublicRoomDirectory", () => {
});
it("should recover from a server exception", async () => {
cli.publicRooms = () => { throw new Error("Oops"); };
cli.publicRooms = () => {
throw new Error("Oops");
};
const query = "ROOM NAME";
const wrapper = mount(<PublicRoomComponent onClick={(hook) => {
hook.search({
limit: 1,
query,
});
}} />);
const wrapper = mount(
<PublicRoomComponent
onClick={(hook) => {
hook.search({
limit: 1,
query,
});
}}
/>,
);
await act(async () => {
await sleep(1);
wrapper.simulate("click");