Change how components get dependencies injected to avoid callback nesting

This commit is contained in:
Alejandro Celaya
2023-09-03 11:06:35 +02:00
parent 4677c24242
commit 046f79270a
4 changed files with 84 additions and 36 deletions

View File

@@ -2,18 +2,20 @@ import { render, screen } from '@testing-library/react';
import { fromPartial } from '@total-typescript/shoehorn';
import { createMemoryHistory } from 'history';
import { Router } from 'react-router-dom';
import { App as createApp } from '../../src/app/App';
import { AppFactory } from '../../src/app/App';
describe('<App />', () => {
const App = createApp(
() => <>MainHeader</>,
() => <>Home</>,
() => <>ShlinkWebComponentContainer</>,
() => <>CreateServer</>,
() => <>EditServer</>,
() => <>SettingsComp</>,
() => <>ManageServers</>,
() => <>ShlinkVersions</>,
const App = AppFactory(
fromPartial({
MainHeader: () => <>MainHeader</>,
Home: () => <>Home</>,
ShlinkWebComponentContainer: () => <>ShlinkWebComponentContainer</>,
CreateServer: () => <>CreateServer</>,
EditServer: () => <>EditServer</>,
Settings: () => <>SettingsComp</>,
ManageServers: () => <>ManageServers</>,
ShlinkVersionsContainer: () => <>ShlinkVersions</>,
}),
);
const setUp = (activeRoute = '/') => {
const history = createMemoryHistory();