You've already forked matrix-react-sdk
mirror of
https://github.com/matrix-org/matrix-react-sdk.git
synced 2025-07-31 13:44:28 +03:00
Migrate useTopic test to RTL (#9580)
This commit is contained in:
@ -16,9 +16,8 @@ limitations under the License.
|
|||||||
|
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { Room } from "matrix-js-sdk/src/models/room";
|
import { Room } from "matrix-js-sdk/src/models/room";
|
||||||
// eslint-disable-next-line deprecate/import
|
|
||||||
import { mount } from "enzyme";
|
|
||||||
import { act } from "react-dom/test-utils";
|
import { act } from "react-dom/test-utils";
|
||||||
|
import { render, screen } from "@testing-library/react";
|
||||||
|
|
||||||
import { useTopic } from "../src/hooks/room/useTopic";
|
import { useTopic } from "../src/hooks/room/useTopic";
|
||||||
import { mkEvent, stubClient } from "./test-utils";
|
import { mkEvent, stubClient } from "./test-utils";
|
||||||
@ -46,9 +45,9 @@ describe("useTopic", () => {
|
|||||||
return <p>{ topic.text }</p>;
|
return <p>{ topic.text }</p>;
|
||||||
}
|
}
|
||||||
|
|
||||||
const wrapper = mount(<RoomTopic />);
|
render(<RoomTopic />);
|
||||||
|
|
||||||
expect(wrapper.text()).toBe("Test topic");
|
expect(screen.queryByText("Test topic")).toBeInTheDocument();
|
||||||
|
|
||||||
const updatedTopic = mkEvent({
|
const updatedTopic = mkEvent({
|
||||||
type: 'm.room.topic',
|
type: 'm.room.topic',
|
||||||
@ -65,6 +64,6 @@ describe("useTopic", () => {
|
|||||||
room.addLiveEvents([updatedTopic]);
|
room.addLiveEvents([updatedTopic]);
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(wrapper.text()).toBe("New topic");
|
expect(screen.queryByText("New topic")).toBeInTheDocument();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user