Skip to content

Commit fc49bd3

Browse files
committed
test: add tests for link tag parsing and intermediate state handling
1 parent 840f871 commit fc49bd3

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

test/link-parsing.test.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,24 @@ describe('link parsing', () => {
6161
expect(containsBare).toBe(true)
6262
})
6363

64+
it('test the link tag', () => {
65+
const nodes = parseMarkdownToStructure(`<a href="https://example.com">Example</a>`, md) as any
66+
const p = nodes[0]
67+
const children = p.children
68+
expect(children.length).toBe(1)
69+
const link = p.children[0]
70+
expect(link.type).toBe('link')
71+
expect(link.href).toBe('https://example.com')
72+
expect(link.text).toBe('Example')
73+
expect(link.children[0].type).toBe('text')
74+
expect(link.children[0].content).toBe('Example')
75+
})
76+
77+
it('test the intermediate state of the link tag', () => {
78+
const nodes = parseMarkdownToStructure(`<a href="https://example.com">`, md) as any
79+
expect(nodes.length).toBe(0)
80+
})
81+
6482
it('parses link with parentheses and CJK brackets as a single link', () => {
6583
const special = '[【名称】(test).mp4](https://github.com/Simon-He95/vue-markdown-renderer)'
6684
const nodes = parseMarkdownToStructure(special, md)

test/playground-share.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { describe, it, expect } from 'vitest'
21
import { compressToEncodedURIComponent, decompressFromEncodedURIComponent } from 'lz-string'
2+
import { describe, expect, it } from 'vitest'
33

44
function makeDataForUrl(input: string) {
55
const encodedRaw = encodeURIComponent(input)

0 commit comments

Comments
 (0)