import { outdent } from "outdent";
runFormatTest(
{
importMeta: import.meta,
snippets: [
...[
// https://developer.mozilla.org/en-US/docs/Glossary/Whitespace#In_HTML
// single
"\u0009",
"\u000A",
"\u000C",
"\u000D",
"\u0020",
// many
"\u0009\u000A\u000C\u000D\u0020",
].map((textContent) => ({
code: `
${textContent}
`,
name: "should be empty",
output: "\n",
})),
...[
// single
"\u0009",
"\u000A",
"\u000C",
"\u000D",
"\u0020",
// many
"\u0009\u000A\u000C\u000D\u0020",
].map((textContent) => ({
code: `${textContent}`,
name: "should keep one space",
output: " \n",
})),
...[
// single
"\u0009",
"\u000A",
"\u000C",
"\u000D",
"\u0020",
].map((textContent) => ({
code: `
${textContent}
`,
name: "between",
output: "
\n",
})),
{
code: "
\u0009\u000A\u000C\u000D\u0020
",
output: "
\n\n
\n",
},
// non-space
...[
"\u2005",
" \u2005 ",
" \u2005\u2005 ",
" \u2005 \u2005 ",
].map((textContent) => `${textContent}
`),
...[
"\u2005",
" \u2005 ",
" \u2005\u2005 ",
" \u2005 \u2005 ",
].map((textContent) => `${textContent}`),
...[
"\u2005",
" \u2005 ",
" \u2005\u2005 ",
" \u2005 \u2005 ",
].map((textContent) => `
${textContent}
`),
// #7103 minimal reproduction
" \u2005 | \u2005 ",
// #7103
"X \u2005 or \u2005 Y
X \u2005 or \u2005 Y
",
// This test maybe not good, `U+2005` there don't make sense,
// but the node has to be `whitespaceSensitive` and `indentationSensitive`,
// to make the `whitespace check logic` work.
{
name: "`U+2005` should indent like `U+005F` not like `U+0020`",
code: outdent`
`,
},
{
name: "`U+2005` should format like `U+005F` not like `U+0020`",
code: outdent`
before\u2005afterafterafterafterafterafterafterafterafterafterafterafterafterafterafterafterafterafterafterafter
before\u005Fafterafterafterafterafterafterafterafterafterafterafterafterafterafterafterafterafterafterafterafter
before\u0020afterafterafterafterafterafterafterafterafterafterafterafterafterafterafterafterafterafterafterafter
`,
},
],
},
["html"],
);