|
| 1 | +import { expect, test } from '@rstest/core'; |
| 2 | +import { renderToMarkdownString } from 'react-render-to-markdown'; |
| 3 | +import { BlogList, type BlogListItem } from './index'; |
| 4 | + |
| 5 | +const posts: BlogListItem[] = [ |
| 6 | + { |
| 7 | + title: 'Announcing Rspack 2.0', |
| 8 | + href: '/blog/announcing-2-0', |
| 9 | + date: '2026-04-22', |
| 10 | + description: |
| 11 | + 'Rspack 2.0 is out with modern defaults, API design, and build outputs.', |
| 12 | + authors: [ |
| 13 | + { |
| 14 | + name: 'Rspack Team', |
| 15 | + avatar: 'https://rspack.rs/logo.png', |
| 16 | + }, |
| 17 | + ], |
| 18 | + }, |
| 19 | + { |
| 20 | + title: 'Bundler tree shaking principles and differences', |
| 21 | + href: '/blog/tree-shaking', |
| 22 | + date: '2025-07-31', |
| 23 | + description: |
| 24 | + 'A brief overview of tree shaking principles across different bundlers.', |
| 25 | + authors: [ |
| 26 | + { |
| 27 | + name: 'ahabhgk', |
| 28 | + avatar: 'https://github.com/ahabhgk.png', |
| 29 | + }, |
| 30 | + ], |
| 31 | + }, |
| 32 | +]; |
| 33 | + |
| 34 | +test('renders blog list as markdown when SSG_MD is enabled', async () => { |
| 35 | + const markdown = await renderToMarkdownString( |
| 36 | + <BlogList |
| 37 | + posts={posts} |
| 38 | + lang="en" |
| 39 | + title="Rspack blogs" |
| 40 | + subtitle={ |
| 41 | + <> |
| 42 | + Browse release notes and technical deep dives from{' '} |
| 43 | + <a href="https://x.com/rspack_dev">@rspack_dev</a>. |
| 44 | + </> |
| 45 | + } |
| 46 | + />, |
| 47 | + ); |
| 48 | + |
| 49 | + expect(markdown).toMatchInlineSnapshot(` |
| 50 | + "# Rspack blogs |
| 51 | +
|
| 52 | + Browse release notes and technical deep dives from @rspack_dev. |
| 53 | +
|
| 54 | + ## [Announcing Rspack 2.0](/blog/announcing-2-0) |
| 55 | +
|
| 56 | + > April 22, 2026 · Rspack Team |
| 57 | +
|
| 58 | + Rspack 2.0 is out with modern defaults, API design, and build outputs. |
| 59 | +
|
| 60 | + ## [Bundler tree shaking principles and differences](/blog/tree-shaking) |
| 61 | +
|
| 62 | + > July 31, 2025 · ahabhgk |
| 63 | +
|
| 64 | + A brief overview of tree shaking principles across different bundlers. |
| 65 | + " |
| 66 | + `); |
| 67 | +}); |
0 commit comments