-
Notifications
You must be signed in to change notification settings - Fork 66.9k
Expand file tree
/
Copy pathmarkdown.ts
More file actions
41 lines (38 loc) · 1.34 KB
/
markdown.ts
File metadata and controls
41 lines (38 loc) · 1.34 KB
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
30
31
32
33
34
35
36
37
38
39
40
41
import { describe, expect, test } from 'vitest'
import type { CheerioAPI } from 'cheerio'
import { getDOM } from '@/tests/helpers/e2etest'
describe('markdown rendering', () => {
test('markdown in intro', async () => {
const $: CheerioAPI = await getDOM('/get-started/markdown/intro')
const html = $('[data-testid="lead"]').html()
expect(html).toMatch('<strong>Markdown</strong>')
expect(html).toMatch('<code>syntax</code>')
expect(html).toMatch('<em>HubGit</em>')
})
})
describe('alerts', () => {
test('basic rendering', async () => {
const $: CheerioAPI = await getDOM('/get-started/markdown/alerts')
const alerts = $('#article-contents .ghd-alert')
// See src/fixtures/fixtures/content/get-started/markdown/alerts.md
// to be this confident in the assertions.
expect(alerts.length).toBe(5)
const svgs = $('svg', alerts)
expect(svgs.length).toBe(5)
const titles = $('.ghd-alert-title', alerts)
.map((_, el) => $(el).text())
.get()
expect(titles).toEqual(['Tip', 'Note', 'Important', 'Warning', 'Caution'])
const bodies = $('p:nth-child(2)', alerts)
.map((_, el) => $(el).text())
.get()
.map((s: string) => s.trim())
expect(bodies).toEqual([
"Here's a free tip",
'A note.',
'This is important',
'Just a warning',
'Be careful!',
])
})
})