release: WRNexusJS 0.8.0
This commit is contained in:
@@ -255,3 +255,48 @@ test("formats v0.6 grouped state and outputs blocks", () => {
|
||||
/\n {2}outputs \{\n {4}confirm\(payload: ConfirmPayload\)\n {4}cancel\(\)\n {2}\}/,
|
||||
);
|
||||
});
|
||||
|
||||
test("preserves preformatted WRN code examples", () => {
|
||||
const source = `page Docs {
|
||||
view {
|
||||
<pre><code><span class="code-muted">// One project, one language</span>
|
||||
<span class="code-key">page</span> ProductDashboard {
|
||||
<span class="code-key">state</span> count: number = 0
|
||||
<button @click='count++'>Ship {count}</button>
|
||||
}</code></pre>
|
||||
}
|
||||
}
|
||||
`;
|
||||
const options = { insertSpaces: true, tabSize: 2, printWidth: 100 };
|
||||
const formatted = formatWrn(source, options);
|
||||
assert.match(
|
||||
formatted,
|
||||
/<pre><code><span class="code-muted">\/\/ One project, one language<\/span>\n<span class="code-key">page<\/span>/,
|
||||
);
|
||||
assert.equal(formatWrn(formatted, options), formatted);
|
||||
});
|
||||
|
||||
test("keeps attribute-free opening tags intact when content is long", () => {
|
||||
const source = `page Docs {
|
||||
view {
|
||||
<p>This documentation sentence is deliberately long enough to exceed the formatter print width without splitting the p opening delimiter.</p>
|
||||
}
|
||||
}
|
||||
`;
|
||||
const options = { insertSpaces: true, tabSize: 2, printWidth: 70 };
|
||||
const formatted = formatWrn(source, options);
|
||||
assert.match(formatted, /^ {4}<p>$/m);
|
||||
assert.doesNotMatch(formatted, /^ {4}<p\n {4}>$/m);
|
||||
assert.equal(formatWrn(formatted, options), formatted);
|
||||
});
|
||||
|
||||
test("preserves balanced compact sibling markup without indentation drift", () => {
|
||||
const source = `page Compact {
|
||||
view {
|
||||
<div class="strip"><span>Page</span><b>→</b><span>API</span></div>
|
||||
}
|
||||
}\n`;
|
||||
const formatted = formatWrn(source, { tabSize: 2, printWidth: 80 });
|
||||
assert.match(formatted, /<div class="strip"><span>Page<\/span><b>→<\/b><span>API<\/span><\/div>/);
|
||||
assert.equal(formatWrn(formatted, { tabSize: 2, printWidth: 80 }), formatted);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user