import { GFM, parser } from "@lezer/markdown"
import { describe, expect, it } from "vitest"
import { createMarkdownExtensions } from "@/lib/markdown-extensions"

const markdownParser = parser.configure([GFM, ...createMarkdownExtensions()])

describe("Debug Tag parser", () => {
  it("single line #tag", () => {
    const text = "#tag more text"
    const tree = markdownParser.parse(text)
    const names: string[] = []
    tree.iterate({
      enter(node) {
        names.push(node.name)
      },
    })
    expect(names).toContain("Tag")
  })

  it("tag after blank line", () => {
    const text = "some text\n\n#tag more text"
    const tree = markdownParser.parse(text)
    const names: string[] = []
    tree.iterate({
      enter(node) {
        names.push(node.name)
      },
    })
    expect(names).toContain("Tag")
  })
})
