-
-
Save sp3ber/3e7e314a6e00efed41394bd7ab049972 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React from 'react'; | |
| import { appSimulator } from '@tramvai/test'; | |
| import { CommonModule } from '@tramvai/module-common'; | |
| import { | |
| CONTEXT_TOKEN, | |
| REQUEST_MANAGER_TOKEN, | |
| COMPONENT_REGISTRY_TOKEN, | |
| } from '@tramvai/tokens-common'; | |
| import { commandLineListTokens } from '@tramvai/core'; | |
| import { DI_TOKEN } from 'dippy'; | |
| import { render, screen } from '@testing-library/react'; | |
| import { Provider } from '@tramvai/state'; | |
| import { DIContext } from '@tramvai/react'; | |
| describe('test', () => { | |
| it('context', async () => { | |
| const { runLine } = appSimulator({ | |
| modules: [CommonModule], | |
| providers: [ | |
| { | |
| provide: REQUEST_MANAGER_TOKEN, | |
| useValue: { | |
| getClientIp: () => '111', | |
| getBody: () => Promise.resolve(), | |
| }, | |
| }, | |
| { | |
| provide: commandLineListTokens.generatePage, | |
| useFactory: (deps) => () => { | |
| return render( | |
| <Provider context={deps.consumerContext}> | |
| <DIContext.Provider value={deps.di}> | |
| <div>hello world</div> | |
| </DIContext.Provider> | |
| </Provider> | |
| ); | |
| }, | |
| multi: true, | |
| deps: { | |
| componentRegistry: COMPONENT_REGISTRY_TOKEN, | |
| consumerContext: CONTEXT_TOKEN, | |
| di: DI_TOKEN, | |
| }, | |
| }, | |
| ], | |
| }); | |
| await runLine('server', 'customer'); | |
| screen.getByText('hello world'); | |
| }); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment