1
0
mirror of https://github.com/matrix-org/matrix-react-sdk.git synced 2025-08-09 08:42:50 +03:00

Update usages of test utilities preferring RTL (#10203)

This commit is contained in:
Michael Telatynski
2023-02-22 10:52:55 +00:00
committed by GitHub
parent 17bbd4eaac
commit c29e5f18ff
37 changed files with 341 additions and 424 deletions

View File

@@ -14,37 +14,32 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
import { render } from "@testing-library/react";
import React from "react";
import { renderIntoDocument } from "react-dom/test-utils";
import Heading from "../../../../src/components/views/typography/Heading";
describe("<Heading />", () => {
const defaultProps = {
size: "h1",
children: <div>test</div>,
["data-test-id"]: "test",
className: "test",
"size": "h1",
"children": <div>test</div>,
"data-testid": "test",
"className": "test",
} as any;
const getComponent = (props = {}) => {
const wrapper = renderIntoDocument<HTMLDivElement>(
<div>
<Heading {...defaultProps} {...props} />
</div>,
) as HTMLDivElement;
return wrapper.children[0];
return render(<Heading {...defaultProps} {...props} />);
};
it("renders h1 with correct attributes", () => {
expect(getComponent({ size: "h1" })).toMatchSnapshot();
expect(getComponent({ size: "h1" }).asFragment()).toMatchSnapshot();
});
it("renders h2 with correct attributes", () => {
expect(getComponent({ size: "h2" })).toMatchSnapshot();
expect(getComponent({ size: "h2" }).asFragment()).toMatchSnapshot();
});
it("renders h3 with correct attributes", () => {
expect(getComponent({ size: "h3" })).toMatchSnapshot();
expect(getComponent({ size: "h3" }).asFragment()).toMatchSnapshot();
});
it("renders h4 with correct attributes", () => {
expect(getComponent({ size: "h4" })).toMatchSnapshot();
expect(getComponent({ size: "h4" }).asFragment()).toMatchSnapshot();
});
});