Skip to content

Instantly share code, notes, and snippets.

@SuperOleg39
Forked from sp3ber/test.tsx
Last active August 20, 2020 15:48
Show Gist options
  • Select an option

  • Save SuperOleg39/afa8264b28484cedb5c7f8adf79b8452 to your computer and use it in GitHub Desktop.

Select an option

Save SuperOleg39/afa8264b28484cedb5c7f8adf79b8452 to your computer and use it in GitHub Desktop.
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 { getToken } = appSimulator({
modules: [CommonModule],
providers: [
{
provide: REQUEST_MANAGER_TOKEN,
useValue: {
getClientIp: () => '111',
getBody: () => Promise.resolve(),
},
},
],
});
render(
<Provider context={getToken(CONTEXT_TOKEN)}>
<DIContext.Provider value={getToken(DI_TOKEN)}>
<div>hello world</div>
</DIContext.Provider>
</Provider>
)
screen.getByText('hello world');
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment