-
Notifications
You must be signed in to change notification settings - Fork 161
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
62 changed files
with
282 additions
and
264 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
'@rocket.chat/fuselage-hooks': minor | ||
'@rocket.chat/fuselage': patch | ||
--- | ||
|
||
Enables hooks' compatibility with React 18 |
This file was deleted.
Oops, something went wrong.
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 type { Config } from 'jest'; | ||
|
||
export default { | ||
projects: [ | ||
{ | ||
displayName: 'React 17', | ||
preset: 'ts-jest', | ||
errorOnDeprecated: true, | ||
testMatch: [ | ||
'<rootDir>/src/**/*.spec.{ts,tsx}', | ||
'!**/*.server.spec.{ts,tsx}', | ||
], | ||
testEnvironment: 'jsdom', | ||
setupFilesAfterEnv: ['testing-utils/setup/noErrorsLogged'], | ||
moduleNameMapper: { | ||
'^react($|/.+)': 'react$1', | ||
'^react-dom/client$': 'react-dom$1', | ||
'^react-dom($|/.+)': 'react-dom$1', | ||
}, | ||
}, | ||
{ | ||
displayName: 'React 17 SSR', | ||
preset: 'ts-jest', | ||
errorOnDeprecated: true, | ||
testMatch: ['<rootDir>/src/**/*.server.spec.{ts,tsx}'], | ||
testEnvironment: 'node', | ||
setupFilesAfterEnv: ['testing-utils/setup/noErrorsLogged'], | ||
moduleNameMapper: { | ||
'^react($|/.+)': 'react$1', | ||
'^react-dom/client$': 'react-dom$1', | ||
'^react-dom($|/.+)': 'react-dom$1', | ||
}, | ||
}, | ||
{ | ||
displayName: 'React 18', | ||
preset: 'ts-jest', | ||
errorOnDeprecated: true, | ||
testMatch: [ | ||
'<rootDir>/src/**/*.spec.{ts,tsx}', | ||
'!**/*.server.spec.{ts,tsx}', | ||
], | ||
testEnvironment: 'jsdom', | ||
setupFilesAfterEnv: [ | ||
'testing-utils/setup/noErrorsLogged', | ||
'<rootDir>/src/jest-setup.ts', | ||
], | ||
moduleNameMapper: { | ||
'^react($|/.+)': 'react18$1', | ||
'^react-dom($|/.+)': 'react-dom18$1', | ||
}, | ||
}, | ||
{ | ||
displayName: 'React 18 SSR', | ||
preset: 'ts-jest', | ||
errorOnDeprecated: true, | ||
testMatch: ['<rootDir>/src/**/*.server.spec.{ts,tsx}'], | ||
testEnvironment: 'node', | ||
setupFilesAfterEnv: [ | ||
'testing-utils/setup/noErrorsLogged', | ||
'<rootDir>/src/jest-setup.ts', | ||
], | ||
moduleNameMapper: { | ||
'^react($|/.+)': 'react18$1', | ||
'^react-dom($|/.+)': 'react-dom18$1', | ||
}, | ||
}, | ||
], | ||
} satisfies Config; |
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,3 @@ | ||
import { configure } from '@testing-library/react'; | ||
|
||
configure({ reactStrictMode: true }); |
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,45 @@ | ||
import { | ||
queries, | ||
Queries, | ||
RenderHookOptions, | ||
RenderHookResult, | ||
renderHook as _renderHook, | ||
} from '@testing-library/react'; | ||
import { createElement } from 'react'; | ||
import * as ReactDOMClient from 'react-dom'; | ||
import { renderToString } from 'react-dom/server'; | ||
|
||
type RendererableContainer = Element | Document | DocumentFragment; | ||
|
||
export function renderHook< | ||
Result, | ||
Props, | ||
Q extends Queries = typeof queries, | ||
Container extends RendererableContainer = HTMLElement, | ||
BaseElement extends RendererableContainer = Container, | ||
>( | ||
render: (initialProps: Props) => Result, | ||
options?: RenderHookOptions<Props, Q, Container, BaseElement> | undefined, | ||
): RenderHookResult<Result, Props> { | ||
if (typeof document === 'undefined') { | ||
let current: Result; | ||
const TestComponent = () => { | ||
current = render(options?.initialProps as any); | ||
return null; | ||
}; | ||
|
||
renderToString(createElement(TestComponent)); | ||
|
||
return { | ||
result: { current: current! }, | ||
rerender: () => undefined, | ||
unmount: () => undefined, | ||
}; | ||
} | ||
|
||
if ('createRoot' in ReactDOMClient) return _renderHook(render, options); | ||
|
||
return _renderHook(render, { ...options, legacyRoot: true }); | ||
} | ||
|
||
export { act } from '@testing-library/react'; |
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
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
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
7 changes: 1 addition & 6 deletions
7
packages/fuselage-hooks/src/useDebouncedCallback.server.spec.ts
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
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
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
Oops, something went wrong.