-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
356 additions
and
110 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import type { PropsWithChildren, ComponentType as _ComponentType, FC as _FC } from 'react'; | ||
|
||
type PropsWithoutChildren<P> = P extends any ? ('children' extends keyof P ? Pick<P, Exclude<keyof P, 'children'>> : P) : P; | ||
|
||
// eslint-disable-next-line @typescript-eslint/ban-types | ||
export type FC<P = {}> = _FC<PropsWithoutChildren<P>>; | ||
|
||
// eslint-disable-next-line @typescript-eslint/ban-types | ||
export type FCC<P = {}> = _FC<PropsWithChildren<P>>; | ||
|
||
// TODO: maybe incompatible | ||
export type { _ComponentType as ComponentType }; |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import React from 'react'; | ||
import renderer from 'react-test-renderer'; | ||
|
||
import { waitForSuspense } from './suspense.js'; | ||
|
||
import { | ||
DEFAULT_PROPS, | ||
Module, | ||
NOOP, | ||
SUSPENSE | ||
} from './shared.js'; | ||
|
||
describe('components', () => { | ||
it('component TranslationRender', async () => { | ||
expect.assertions(2); | ||
|
||
const component = renderer.create( | ||
React.createElement( | ||
Module.TranslationProvider, | ||
DEFAULT_PROPS, | ||
React.createElement( | ||
React.Suspense, | ||
{ | ||
fallback: SUSPENSE | ||
}, | ||
React.createElement( | ||
Module.TranslationRender, | ||
{ | ||
path: DEFAULT_PROPS.language | ||
} | ||
) | ||
) | ||
) | ||
); | ||
|
||
expect(component.toJSON()).toBe(SUSPENSE); | ||
|
||
await renderer.act(NOOP); | ||
await waitForSuspense(NOOP); | ||
|
||
expect(component.toJSON()).toBe(DEFAULT_PROPS.language); | ||
}); | ||
|
||
it('component Translation', async () => { | ||
expect.assertions(2); | ||
|
||
const component = renderer.create( | ||
React.createElement( | ||
Module.TranslationProvider, | ||
DEFAULT_PROPS, | ||
React.createElement( | ||
Module.Translation, | ||
{ | ||
path: DEFAULT_PROPS.language | ||
}, | ||
SUSPENSE | ||
) | ||
) | ||
); | ||
|
||
expect(component.toJSON()).toBe(SUSPENSE); | ||
|
||
await renderer.act(NOOP); | ||
await waitForSuspense(NOOP); | ||
|
||
expect(component.toJSON()).toBe(DEFAULT_PROPS.language); | ||
}); | ||
}); |
Oops, something went wrong.