Browse Source

test(ui): Switch children to react nodes (#66390)

- adds a missing children prop, swaps ReactElement to ReactNode
- removes a render function used as a child
Scott Cooper 1 year ago
parent
commit
a023729aef

+ 4 - 3
static/app/components/noProjectMessage.spec.tsx

@@ -18,15 +18,16 @@ describe('NoProjectMessage', function () {
 
   it('renders', function () {
     const organization = OrganizationFixture({slug: 'org-slug'});
-    const childrenMock = jest.fn().mockReturnValue(null);
     ProjectsStore.loadInitialData([]);
 
     render(
-      <NoProjectMessage organization={organization}>{childrenMock}</NoProjectMessage>
+      <NoProjectMessage organization={organization}>
+        <div data-test-id="child">Test</div>
+      </NoProjectMessage>
     );
 
-    expect(childrenMock).not.toHaveBeenCalled();
     expect(screen.getByText('Remain Calm')).toBeInTheDocument();
+    expect(screen.queryByTestId('child')).not.toBeInTheDocument();
   });
 
   it('shows "Create Project" button when there are no projects', function () {

+ 1 - 1
static/app/stores/guideStore.spec.tsx

@@ -120,7 +120,7 @@ describe('GuideStore', function () {
   it('hides when a modal is open', function () {
     expect(GuideStore.getState().forceHide).toBe(false);
 
-    ModalStore.openModal(() => {}, {});
+    ModalStore.openModal(() => <div />, {});
 
     expect(GuideStore.getState().forceHide).toBe(true);
 

+ 1 - 2
static/app/utils/profiling/hooks/useProfileFunctionTrends.spec.tsx

@@ -1,4 +1,3 @@
-import type {ReactElement} from 'react';
 import {useMemo} from 'react';
 
 import {initializeOrg} from 'sentry-test/initializeOrg';
@@ -9,7 +8,7 @@ import {useProfileFunctionTrends} from 'sentry/utils/profiling/hooks/useProfileF
 import {QueryClientProvider} from 'sentry/utils/queryClient';
 import {OrganizationContext} from 'sentry/views/organizationContext';
 
-function TestContext({children}: {children: ReactElement}) {
+function TestContext({children}: {children: React.ReactNode}) {
   const {organization} = useMemo(() => initializeOrg(), []);
 
   return (

+ 1 - 2
static/app/utils/profiling/hooks/useProfileFunctions.spec.tsx

@@ -1,4 +1,3 @@
-import type {ReactElement} from 'react';
 import {useMemo} from 'react';
 
 import {initializeOrg} from 'sentry-test/initializeOrg';
@@ -9,7 +8,7 @@ import {useProfileFunctions} from 'sentry/utils/profiling/hooks/useProfileFuncti
 import {QueryClientProvider} from 'sentry/utils/queryClient';
 import {OrganizationContext} from 'sentry/views/organizationContext';
 
-function TestContext({children}: {children: ReactElement}) {
+function TestContext({children}: {children: React.ReactNode}) {
   const {organization} = useMemo(() => initializeOrg(), []);
 
   return (

+ 1 - 1
tests/js/sentry-test/reactTestingLibrary.tsx

@@ -38,7 +38,7 @@ type ProviderOptions = {
 type Options = ProviderOptions & rtl.RenderOptions;
 
 function createProvider(contextDefs: Record<string, any>) {
-  return class ContextProvider extends Component {
+  return class ContextProvider extends Component<{children?: React.ReactNode}> {
     static childContextTypes = contextDefs.childContextTypes;
 
     getChildContext() {