release: WRNexusJS 0.8.0
This commit is contained in:
@@ -37,3 +37,49 @@ view {
|
||||
expect(formatted).not.toContain("\r");
|
||||
});
|
||||
});
|
||||
|
||||
test("preserves preformatted code examples while formatting surrounding markup", () => {
|
||||
const source = `page Docs {
|
||||
view {
|
||||
<section class="docs">
|
||||
<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>
|
||||
</section>
|
||||
}
|
||||
}
|
||||
`;
|
||||
const formatted = formatWrn(source, options);
|
||||
expect(formatted)
|
||||
.toContain(`<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`);
|
||||
expect(formatWrn(formatted, options)).toBe(formatted);
|
||||
expect(() => parse(formatted)).not.toThrow();
|
||||
});
|
||||
|
||||
test("does not split an attribute-free opening tag delimiter", () => {
|
||||
const source = `page Docs {
|
||||
view {
|
||||
<p>This is intentionally long documentation copy that should wrap as content without formatting the opening p tag as separate less-than and greater-than lines.</p>
|
||||
}
|
||||
}
|
||||
`;
|
||||
const formatted = formatWrn(source, options);
|
||||
expect(formatted).toContain(" <p>\n");
|
||||
expect(formatted).not.toContain(" <p\n >");
|
||||
expect(formatWrn(formatted, options)).toBe(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 });
|
||||
expect(formatted).toContain('<div class="strip"><span>Page</span><b>→</b><span>API</span></div>');
|
||||
expect(formatWrn(formatted, { tabSize: 2, printWidth: 80 })).toBe(formatted);
|
||||
});
|
||||
|
||||
@@ -200,3 +200,10 @@ test("parses edge and worker execution targets", () => {
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
test("maps literal unions to their runtime primitive types", async () => {
|
||||
const { runtimeTypeOf } = await import("../src/types.ts");
|
||||
expect(runtimeTypeOf('"_blank" | "_self"')).toBe("string");
|
||||
expect(runtimeTypeOf("1 | 2 | 3")).toBe("number");
|
||||
expect(runtimeTypeOf("true | false")).toBe("boolean");
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user