import { describe, test, beforeAll } from "vitest" import { Herb } from "@herb-tools/node-wasm" import { HTMLAttributeNode, HTMLAttributeNameNode, HTMLAttributeValueNode } from "@herb-tools/core" import { expectNodeToPrint, expectPrintRoundTrip, location, createToken, createLiteralNode } from "../helpers/printer-test-helpers.js" const name = HTMLAttributeNameNode.build({ location, children: [ createLiteralNode("id") ] }) const value = HTMLAttributeValueNode.build({ location, open_quote: createToken("TOKEN_QUOTE", `"`), close_quote: createToken("TOKEN_QUOTE", `"`), children: [ createLiteralNode("value") ], quoted: true }) describe("HTMLAttributeNode Printing", () => { beforeAll(async () => { await Herb.load() }) test("can print from node", () => { const node = HTMLAttributeNode.build({ location, name, equals: createToken("TOKEN_EQUALS", "="), value }) expectNodeToPrint(node, `id="value"`) }) test("can print from source", () => { expectPrintRoundTrip(`
`) expectPrintRoundTrip(`
`) expectPrintRoundTrip(`
`) }) test("preserve whitespace", () => { expectPrintRoundTrip(`
`) }) })