Skip to content

Commit

Permalink
Allow rendring no props to component
Browse files Browse the repository at this point in the history
  • Loading branch information
standeren committed Oct 30, 2024
1 parent b20b8b5 commit 50025ce
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 63 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from 'react';
import { render, screen } from '@testing-library/react';
import { AppContentLibrary } from './AppContentLibrary';
import { textMock } from '@studio/testing/mocks/i18nMock';
import { BrowserRouter } from 'react-router-dom';

describe('AppContentLibrary', () => {
it('renders the AppContentLibrary with codeLists and images resources', () => {
Expand All @@ -20,5 +21,9 @@ describe('AppContentLibrary', () => {
});

const renderAppContentLibrary = () => {
render(<AppContentLibrary />);
render(
<BrowserRouter>
<AppContentLibrary />
</BrowserRouter>,
);
};

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,14 @@ export function LibraryContent<T extends PageName = 'landingPage'>({
pages,
currentPage,
}: LibraryContentProps) {
const componentPropsAreExternal = currentPage !== 'landingPage';

const componentProps: Required<PagePropsMap>[T] =
componentPropsAreExternal && (pages[currentPage].props as Required<PagePropsMap>[T]);
const componentProps: Required<PagePropsMap>[T] = pages[currentPage]
?.props as Required<PagePropsMap>[T];

return (
<div className={classes.libraryContent}>
<PagesRouter pageNames={getAllPageNamesFromPagesConfig(pages)} />
<div className={classes.component}>
<Component {...componentProps} />
<Component {...(componentProps ?? {})} />
</div>
<InfoBox pageName={currentPage} />
</div>
Expand Down

0 comments on commit 50025ce

Please sign in to comment.