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
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
37 changed files with 341 additions and 424 deletions

View file

@ -12,8 +12,8 @@ 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 SettingsFieldset from "../../../../src/components/views/settings/SettingsFieldset";
@ -21,24 +21,19 @@ describe("<SettingsFieldset />", () => {
const defaultProps = {
"legend": "Who can read history?",
"children": <div>test</div>,
"data-test-id": "test",
"data-testid": "test",
};
const getComponent = (props = {}) => {
const wrapper = renderIntoDocument<HTMLDivElement>(
<div>
<SettingsFieldset {...defaultProps} {...props} />
</div>,
) as HTMLDivElement;
return wrapper.children[0];
return render(<SettingsFieldset {...defaultProps} {...props} />);
};
it("renders fieldset without description", () => {
expect(getComponent()).toMatchSnapshot();
expect(getComponent().asFragment()).toMatchSnapshot();
});
it("renders fieldset with plain text description", () => {
const description = "Changes to who can read history.";
expect(getComponent({ description })).toMatchSnapshot();
expect(getComponent({ description }).asFragment()).toMatchSnapshot();
});
it("renders fieldset with react description", () => {
@ -48,6 +43,6 @@ describe("<SettingsFieldset />", () => {
<a href="#test">a link</a>
</>
);
expect(getComponent({ description })).toMatchSnapshot();
expect(getComponent({ description }).asFragment()).toMatchSnapshot();
});
});