From 990a0c19a9205fdd8b3e6c0082cc8b80725de144 Mon Sep 17 00:00:00 2001 From: Renaud Chaput Date: Mon, 20 May 2024 09:29:27 +0200 Subject: [PATCH] Fix a warning when running JS Tests because of FakeIdentityContext using deprecated context API (#30368) --- app/javascript/mastodon/test_helpers.tsx | 43 ++++++------------------ 1 file changed, 11 insertions(+), 32 deletions(-) diff --git a/app/javascript/mastodon/test_helpers.tsx b/app/javascript/mastodon/test_helpers.tsx index 69d57b95a0..bfea3f6bf4 100644 --- a/app/javascript/mastodon/test_helpers.tsx +++ b/app/javascript/mastodon/test_helpers.tsx @@ -1,7 +1,3 @@ -import PropTypes from 'prop-types'; -import type { PropsWithChildren } from 'react'; -import { Component } from 'react'; - import { IntlProvider } from 'react-intl'; import { MemoryRouter } from 'react-router'; @@ -9,44 +5,27 @@ import { MemoryRouter } from 'react-router'; // eslint-disable-next-line import/no-extraneous-dependencies import { render as rtlRender } from '@testing-library/react'; -class FakeIdentityWrapper extends Component< - PropsWithChildren<{ signedIn: boolean }> -> { - static childContextTypes = { - identity: PropTypes.shape({ - signedIn: PropTypes.bool.isRequired, - accountId: PropTypes.string, - disabledAccountId: PropTypes.string, - accessToken: PropTypes.string, - }).isRequired, - }; - - getChildContext() { - return { - identity: { - signedIn: this.props.signedIn, - accountId: '123', - accessToken: 'test-access-token', - }, - }; - } - - render() { - return this.props.children; - } -} +import { IdentityContext } from './identity_context'; function render( ui: React.ReactElement, { locale = 'en', signedIn = true, ...renderOptions } = {}, ) { + const fakeIdentity = { + signedIn: signedIn, + accountId: '123', + accessToken: 'test-access-token', + disabledAccountId: undefined, + permissions: 0, + }; + const Wrapper = (props: { children: React.ReactNode }) => { return ( - + {props.children} - + );