import { afterEach, describe, expect, it } from 'vitest'
import { embedRendererFor, linkify, messageUrls, registerEmbedRenderer } from './linkEmbeds'
import { escapeHtml } from './markdown'
const EXTERNAL = 'target="_blank" rel="noopener noreferrer nofollow"'
describe('linkify', () => {
it('links a bare https URL with target and rel set', () => {
expect(linkify('see https://summercms.io/docs now')).toBe(
`see https://summercms.io/docs now`,
)
})
it('links http as well, and only http(s)', () => {
expect(linkify('http://a.example')).toContain(' {
expect(linkify('go to https://a.example/x.')).toBe(`go to https://a.example/x.`)
expect(linkify('(https://a.example/x)')).toBe(`(https://a.example/x)`)
expect(linkify('https://en.wikipedia.org/wiki/Go_(game)')).toContain('href="https://en.wikipedia.org/wiki/Go_(game)"')
expect(linkify('https://a.example/?q=1, then')).toContain('href="https://a.example/?q=1"')
})
it('works on escaped text and adds no markup of the input', () => {
const input = ' https://a.example/?a=1&b='
const out = linkify(escapeHtml(input))
expect(out).not.toContain('