-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMarkdownView.test.tsx
More file actions
29 lines (24 loc) · 1015 Bytes
/
MarkdownView.test.tsx
File metadata and controls
29 lines (24 loc) · 1015 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import { render } from '@testing-library/react'
import { strict as assert } from 'assert'
import { describe, expect, it, vi } from 'vitest'
import { getHyperparamSource } from '../../lib/sources/index.js'
import MarkdownView from './MarkdownView.js'
globalThis.fetch = vi.fn()
describe('MarkdownView Component', () => {
it('renders markdown correctly', async () => {
const text = '# Markdown\n\nThis is a test of the markdown viewer.'
vi.mocked(fetch).mockResolvedValueOnce({
text: () => Promise.resolve(text),
headers: new Map([['content-length', text.length]]),
} as unknown as Response)
const source = getHyperparamSource('test.md', { endpoint: 'http://localhost:3000' })
assert(source?.kind === 'file')
const { findByText } = render(
<MarkdownView source={source} setError={vi.fn()} />
)
expect(fetch).toHaveBeenCalled()
await findByText('Markdown')
await findByText('This is a test of the markdown viewer.')
await findByText('50 b')
})
})