このコミットが含まれているのは:
@@ -33,11 +33,16 @@ export const createHelpFixture = () => {
|
||||
const raw = Object.fromEntries (editionRows.map (([id, language, edition, title, body]) => [
|
||||
`../../help/${id}/editions/${language}/${edition}.mdx`,
|
||||
vi.fn (async () => `# ${title}\n\n${body}`)]))
|
||||
const modules = Object.fromEntries (editionRows.map (([id, language, edition, title, body]) => [
|
||||
const moduleLoads = Object.fromEntries (editionRows.map (([id, language, edition, title, body]) => [
|
||||
`../../help/${id}/editions/${language}/${edition}.mdx`,
|
||||
vi.fn (async (): Promise<{ default: () => ReactElement }> => ({
|
||||
default: () => createElement ('div', null,
|
||||
createElement ('h1', null, title), createElement ('p', null, body)) }))]))
|
||||
// Dynamic imports reuse a module namespace even when called more than once.
|
||||
const modules = Object.fromEntries (Object.entries (moduleLoads).map (([path, load]) => {
|
||||
const cache: { promise?: ReturnType<typeof load> } = { }
|
||||
return [path, vi.fn (() => cache.promise ??= load ())]
|
||||
}))
|
||||
const glob = (pattern: string, options?: { query?: string }) => {
|
||||
if (pattern.endsWith ('article.yml'))
|
||||
return articles
|
||||
@@ -53,7 +58,7 @@ export const createHelpFixture = () => {
|
||||
}
|
||||
new Function ('require', 'exports', 'helpMeta', compiled) (
|
||||
requireFixture, api, { glob })
|
||||
return { api, articles, raw, modules }
|
||||
return { api, articles, raw, modules, moduleLoads }
|
||||
}
|
||||
|
||||
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする