mirror of
https://github.com/mastodon/mastodon.git
synced 2025-05-27 12:07:10 +00:00

Some checks failed
Check i18n / check-i18n (push) Has been cancelled
CodeQL / Analyze (javascript) (push) Has been cancelled
CodeQL / Analyze (ruby) (push) Has been cancelled
Check formatting / lint (push) Has been cancelled
CSS Linting / lint (push) Has been cancelled
JavaScript Linting / lint (push) Has been cancelled
JavaScript Testing / test (push) Has been cancelled
Ruby Testing / build (production) (push) Has been cancelled
Ruby Testing / build (test) (push) Has been cancelled
Ruby Testing / test (.ruby-version) (push) Has been cancelled
Ruby Testing / test (3.2) (push) Has been cancelled
Ruby Testing / test (3.3) (push) Has been cancelled
Ruby Testing / Libvips tests (.ruby-version) (push) Has been cancelled
Ruby Testing / Libvips tests (3.2) (push) Has been cancelled
Ruby Testing / Libvips tests (3.3) (push) Has been cancelled
Ruby Testing / End to End testing (.ruby-version) (push) Has been cancelled
Ruby Testing / End to End testing (3.2) (push) Has been cancelled
Ruby Testing / End to End testing (3.3) (push) Has been cancelled
Ruby Testing / Elastic Search integration testing (.ruby-version, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Has been cancelled
Ruby Testing / Elastic Search integration testing (.ruby-version, docker.elastic.co/elasticsearch/elasticsearch:8.10.2) (push) Has been cancelled
Ruby Testing / Elastic Search integration testing (.ruby-version, opensearchproject/opensearch:2) (push) Has been cancelled
Ruby Testing / Elastic Search integration testing (3.2, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Has been cancelled
Ruby Testing / Elastic Search integration testing (3.3, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Has been cancelled
53 lines
1.3 KiB
TypeScript
53 lines
1.3 KiB
TypeScript
import { IntlProvider } from 'react-intl';
|
|
|
|
import { MemoryRouter } from 'react-router';
|
|
|
|
import type { RenderOptions } from '@testing-library/react';
|
|
import { render as rtlRender } from '@testing-library/react';
|
|
|
|
import { IdentityContext } from './identity_context';
|
|
|
|
beforeAll(() => {
|
|
global.requestIdleCallback = vi.fn((cb: IdleRequestCallback) => {
|
|
// @ts-expect-error IdleRequestCallback expects an argument of type IdleDeadline,
|
|
// but that doesn't exist in this environment.
|
|
cb();
|
|
return 0;
|
|
});
|
|
});
|
|
|
|
function render(
|
|
ui: React.ReactElement,
|
|
{
|
|
locale = 'en',
|
|
signedIn = true,
|
|
...renderOptions
|
|
}: RenderOptions & { locale?: string; signedIn?: boolean } = {},
|
|
) {
|
|
const fakeIdentity = {
|
|
signedIn: signedIn,
|
|
accountId: '123',
|
|
disabledAccountId: undefined,
|
|
permissions: 0,
|
|
};
|
|
|
|
const Wrapper = (props: { children: React.ReactNode }) => {
|
|
return (
|
|
<MemoryRouter>
|
|
<IntlProvider locale={locale}>
|
|
<IdentityContext.Provider value={fakeIdentity}>
|
|
{props.children}
|
|
</IdentityContext.Provider>
|
|
</IntlProvider>
|
|
</MemoryRouter>
|
|
);
|
|
};
|
|
return rtlRender(ui, { wrapper: Wrapper, ...renderOptions });
|
|
}
|
|
|
|
// re-export everything
|
|
export * from '@testing-library/react';
|
|
|
|
// override render method
|
|
export { render };
|