import MarkdownIt from 'markdown-it'
import { describe, expect, it } from 'vitest'
import { linksPlugin } from '../src/node/enhance/links.js'
describe('linksPlugin', () => {
const md = new MarkdownIt({
html: true,
}).use(linksPlugin)
it('should work with external link', () => {
expect(md.render('[link](https://github.com)')).toContain(' {
expect(md.render('[link](#anchor)')).toContain(' {
expect(md.render('[link](/path)')).toContain('')
})
it('should work with internal link extension and empty env', () => {
const env = {}
expect(md.render('[link](/path.md)', env)).toContain('href="/path.md"')
expect(md.render('[link](../path.md)', env)).toContain('href="../path.md"')
})
it('should work with internal link extension and env', () => {
const env = { base: '/', filePathRelative: '../foo.md' }
expect(md.render('[link](/path.html)', env)).toContain('href="/path.html"')
expect(md.render('[link](/path.md)', env)).toContain('href="/path.md"')
expect(md.render('[link](../path.md)', env)).toContain('href="../path.md"')
})
})