element-web-Github/test/components/views/settings/SettingsFieldset-test.tsx

43 lines
1.3 KiB
TypeScript
Raw Normal View History

/*
Copyright 2024 New Vector Ltd.
Copyright 2021 The Matrix.org Foundation C.I.C.
SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only
Please see LICENSE files in the repository root for full details.
*/
import { render } from "jest-matrix-react";
2022-12-12 19:24:14 +08:00
import React from "react";
2022-12-12 19:24:14 +08:00
import SettingsFieldset from "../../../../src/components/views/settings/SettingsFieldset";
2022-12-12 19:24:14 +08:00
describe("<SettingsFieldset />", () => {
const defaultProps = {
2022-12-12 19:24:14 +08:00
"legend": "Who can read history?",
"children": <div>test</div>,
"data-testid": "test",
};
const getComponent = (props = {}) => {
return render(<SettingsFieldset {...defaultProps} {...props} />);
};
2022-12-12 19:24:14 +08:00
it("renders fieldset without description", () => {
expect(getComponent().asFragment()).toMatchSnapshot();
});
2022-12-12 19:24:14 +08:00
it("renders fieldset with plain text description", () => {
const description = "Changes to who can read history.";
expect(getComponent({ description }).asFragment()).toMatchSnapshot();
});
2022-12-12 19:24:14 +08:00
it("renders fieldset with react description", () => {
const description = (
<>
<p>Test</p>
<a href="#test">a link</a>
</>
);
expect(getComponent({ description }).asFragment()).toMatchSnapshot();
});
});