Reviewed-on: #433 Co-authored-by: miteruzo <miteruzo@naver.com>
このコミットはプルリクエスト #433 でマージされました。
このコミットが含まれているのは:
@@ -14,7 +14,7 @@ export const transformMdx = async (source: string, suffix = '.mdx') => {
|
||||
const plugin = plugins.find (entry => entry.name === '@mdx-js/rollup')
|
||||
if (plugin == null)
|
||||
throw new Error ('The application MDX compiler is not registered')
|
||||
return plugin.transform.call (plugin, source, `/test/help-table${suffix}`)
|
||||
return await plugin.transform.call (plugin, source, `/test/help-table${suffix}`) ?? null
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -3,6 +3,8 @@ import { ModuleKind, ScriptTarget, transpileModule } from 'typescript'
|
||||
import { vi } from 'vitest'
|
||||
|
||||
import source from '@/lib/help.ts?raw'
|
||||
import * as locales from '@/lib/locales'
|
||||
import * as queryKeys from '@/lib/queryKeys'
|
||||
|
||||
import type { ComponentType } from 'react'
|
||||
|
||||
@@ -92,6 +94,10 @@ export const createHelpFixture = () => {
|
||||
loaders: vi.fn (() => loaders) }
|
||||
const api = { } as typeof Help
|
||||
const requireFixture = (name: string) => {
|
||||
if (name === '@/lib/locales')
|
||||
return locales
|
||||
if (name === '@/lib/queryKeys')
|
||||
return queryKeys
|
||||
const key = name.replace ('virtual:help/', '') as keyof typeof loads
|
||||
if (Object.hasOwn (loads, key))
|
||||
return loads[key] ()
|
||||
|
||||
+11
-13
@@ -11,8 +11,8 @@ import { UnsavedChangesGuardProvider } from '@/lib/useUnsavedChangesGuard'
|
||||
import type { ReactElement, ReactNode } from 'react'
|
||||
|
||||
type Options = {
|
||||
route?: string
|
||||
}
|
||||
route?: string
|
||||
queryClient?: QueryClient }
|
||||
|
||||
const TestContentContext = createContext<ReactNode> (null)
|
||||
|
||||
@@ -21,21 +21,21 @@ const TestRoute = () => {
|
||||
const children = useContext (TestContentContext)
|
||||
|
||||
return (
|
||||
<UnsavedChangesGuardProvider>
|
||||
<KeyboardShortcutsProvider>
|
||||
{children}
|
||||
</KeyboardShortcutsProvider>
|
||||
</UnsavedChangesGuardProvider>)
|
||||
<DialogueProvider>
|
||||
<UnsavedChangesGuardProvider>
|
||||
<KeyboardShortcutsProvider>
|
||||
{children}
|
||||
</KeyboardShortcutsProvider>
|
||||
</UnsavedChangesGuardProvider>
|
||||
</DialogueProvider>)
|
||||
}
|
||||
|
||||
export const renderWithProviders = (
|
||||
ui: ReactElement,
|
||||
options: Options = {},
|
||||
) => {
|
||||
const queryClient = new QueryClient ({
|
||||
defaultOptions: {
|
||||
queries: { retry: false } },
|
||||
})
|
||||
const queryClient = options.queryClient ?? new QueryClient ({
|
||||
defaultOptions: { queries: { retry: false } } })
|
||||
|
||||
const Wrapper = ({ children }: { children: ReactNode }) => {
|
||||
const [router] = useState (() => createMemoryRouter ([{
|
||||
@@ -46,11 +46,9 @@ export const renderWithProviders = (
|
||||
return (
|
||||
<QueryClientProvider client={queryClient}>
|
||||
<HelmetProvider>
|
||||
<DialogueProvider>
|
||||
<TestContentContext.Provider value={children}>
|
||||
<RouterProvider router={router}/>
|
||||
</TestContentContext.Provider>
|
||||
</DialogueProvider>
|
||||
</HelmetProvider>
|
||||
</QueryClientProvider>)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
import { renderToStaticMarkup } from 'react-dom/server'
|
||||
|
||||
import type { ReactNode } from 'react'
|
||||
|
||||
|
||||
export const textContentOf = (node: ReactNode): string => {
|
||||
const container = document.createElement ('div')
|
||||
container.innerHTML = renderToStaticMarkup (<>{node}</>)
|
||||
return container.textContent ?? ''
|
||||
}
|
||||
新しいイシューから参照
ユーザーをブロックする