1
0
mirror of https://github.com/kremalicious/blog.git synced 2025-01-09 13:18:54 +01:00

Add React component generation test to icon script

This commit is contained in:
Matthias Kretschmann 2023-11-01 21:39:42 +00:00
parent 2ef64cf23d
commit 44baa27326
Signed by: m
GPG Key ID: 606EEEF3C479A91F

View File

@ -9,7 +9,7 @@ afterAll(() => {
fs.rm(path.resolve(__dirname, 'tmp'), { recursive: true }) fs.rm(path.resolve(__dirname, 'tmp'), { recursive: true })
}) })
test('should generate Astro components from SVG files', async () => { test('should generate Astro & React components from SVG files', async () => {
// Act // Act
await generateIcons(distDir) await generateIcons(distDir)
@ -27,13 +27,22 @@ test('should generate Astro components from SVG files', async () => {
throw new Error('Props.d.ts does not exist') throw new Error('Props.d.ts does not exist')
} }
// Assert: Check if an example Astro component exists // Assert: Check if an example Astro & React component exists
const exampleComponentPath = path.join(distDir, 'Bitcoin.astro') const exampleComponentPathAstro = path.join(distDir, 'Bitcoin.astro')
const exampleComponentPathReact = path.join(distDir, 'react', 'Bitcoin.tsx')
try { try {
await fs.stat(exampleComponentPath) await fs.stat(exampleComponentPathAstro)
} catch (err) { } catch (err) {
throw new Error( throw new Error(
`Example Astro component does not exist: ${exampleComponentPath}` `Example Astro component does not exist: ${exampleComponentPathAstro}`
)
}
try {
await fs.stat(exampleComponentPathReact)
} catch (err) {
throw new Error(
`Example React component does not exist: ${exampleComponentPathReact}`
) )
} }
}) })