2021-12-09 20:44:22 +03:00
|
|
|
/*
|
|
|
|
Copyright 2021 The Matrix.org Foundation C.I.C.
|
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2023-02-22 13:52:55 +03:00
|
|
|
import { render } from "@testing-library/react";
|
2022-12-12 14:24:14 +03:00
|
|
|
import React from "react";
|
2021-12-09 20:44:22 +03:00
|
|
|
|
2022-12-12 14:24:14 +03:00
|
|
|
import SettingsFieldset from "../../../../src/components/views/settings/SettingsFieldset";
|
2021-12-09 20:44:22 +03:00
|
|
|
|
2022-12-12 14:24:14 +03:00
|
|
|
describe("<SettingsFieldset />", () => {
|
2021-12-09 20:44:22 +03:00
|
|
|
const defaultProps = {
|
2022-12-12 14:24:14 +03:00
|
|
|
"legend": "Who can read history?",
|
2021-12-09 20:44:22 +03:00
|
|
|
"children": <div>test</div>,
|
2023-02-22 13:52:55 +03:00
|
|
|
"data-testid": "test",
|
2021-12-09 20:44:22 +03:00
|
|
|
};
|
|
|
|
const getComponent = (props = {}) => {
|
2023-02-22 13:52:55 +03:00
|
|
|
return render(<SettingsFieldset {...defaultProps} {...props} />);
|
2021-12-09 20:44:22 +03:00
|
|
|
};
|
|
|
|
|
2022-12-12 14:24:14 +03:00
|
|
|
it("renders fieldset without description", () => {
|
2023-02-22 13:52:55 +03:00
|
|
|
expect(getComponent().asFragment()).toMatchSnapshot();
|
2021-12-09 20:44:22 +03:00
|
|
|
});
|
|
|
|
|
2022-12-12 14:24:14 +03:00
|
|
|
it("renders fieldset with plain text description", () => {
|
|
|
|
const description = "Changes to who can read history.";
|
2023-02-22 13:52:55 +03:00
|
|
|
expect(getComponent({ description }).asFragment()).toMatchSnapshot();
|
2021-12-09 20:44:22 +03:00
|
|
|
});
|
|
|
|
|
2022-12-12 14:24:14 +03:00
|
|
|
it("renders fieldset with react description", () => {
|
|
|
|
const description = (
|
|
|
|
<>
|
|
|
|
<p>Test</p>
|
|
|
|
<a href="#test">a link</a>
|
|
|
|
</>
|
|
|
|
);
|
2023-02-22 13:52:55 +03:00
|
|
|
expect(getComponent({ description }).asFragment()).toMatchSnapshot();
|
2021-12-09 20:44:22 +03:00
|
|
|
});
|
|
|
|
});
|