You've already forked matrix-react-sdk
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:
committed by
GitHub
parent
17bbd4eaac
commit
c29e5f18ff
@@ -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();
|
||||
});
|
||||
});
|
||||
|
@@ -1,45 +1,53 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`<Heading /> renders h1 with correct attributes 1`] = `
|
||||
<h1
|
||||
class="mx_Heading_h1 test"
|
||||
data-test-id="test"
|
||||
>
|
||||
<div>
|
||||
test
|
||||
</div>
|
||||
</h1>
|
||||
<DocumentFragment>
|
||||
<h1
|
||||
class="mx_Heading_h1 test"
|
||||
data-testid="test"
|
||||
>
|
||||
<div>
|
||||
test
|
||||
</div>
|
||||
</h1>
|
||||
</DocumentFragment>
|
||||
`;
|
||||
|
||||
exports[`<Heading /> renders h2 with correct attributes 1`] = `
|
||||
<h2
|
||||
class="mx_Heading_h2 test"
|
||||
data-test-id="test"
|
||||
>
|
||||
<div>
|
||||
test
|
||||
</div>
|
||||
</h2>
|
||||
<DocumentFragment>
|
||||
<h2
|
||||
class="mx_Heading_h2 test"
|
||||
data-testid="test"
|
||||
>
|
||||
<div>
|
||||
test
|
||||
</div>
|
||||
</h2>
|
||||
</DocumentFragment>
|
||||
`;
|
||||
|
||||
exports[`<Heading /> renders h3 with correct attributes 1`] = `
|
||||
<h3
|
||||
class="mx_Heading_h3 test"
|
||||
data-test-id="test"
|
||||
>
|
||||
<div>
|
||||
test
|
||||
</div>
|
||||
</h3>
|
||||
<DocumentFragment>
|
||||
<h3
|
||||
class="mx_Heading_h3 test"
|
||||
data-testid="test"
|
||||
>
|
||||
<div>
|
||||
test
|
||||
</div>
|
||||
</h3>
|
||||
</DocumentFragment>
|
||||
`;
|
||||
|
||||
exports[`<Heading /> renders h4 with correct attributes 1`] = `
|
||||
<h4
|
||||
class="mx_Heading_h4 test"
|
||||
data-test-id="test"
|
||||
>
|
||||
<div>
|
||||
test
|
||||
</div>
|
||||
</h4>
|
||||
<DocumentFragment>
|
||||
<h4
|
||||
class="mx_Heading_h4 test"
|
||||
data-testid="test"
|
||||
>
|
||||
<div>
|
||||
test
|
||||
</div>
|
||||
</h4>
|
||||
</DocumentFragment>
|
||||
`;
|
||||
|
Reference in New Issue
Block a user