release: WRNexusJS 0.5.10
This commit is contained in:
@@ -20,6 +20,69 @@ test("preserves nested prop defaults while formatting", () => {
|
||||
assert.equal(formatWrn(formatted, { insertSpaces: true, tabSize: 2 }), formatted);
|
||||
});
|
||||
|
||||
test("formats native JSON state values with readable indentation", () => {
|
||||
const source = `component Footer {
|
||||
state footerItems = [{"label":"Accessibility","href":"/accessibility","value":"accessibility"},{"label":"Privacy","href":"/privacy","value":"privacy"}]
|
||||
view { <footer></footer> }
|
||||
}
|
||||
`;
|
||||
const expected = `component Footer {
|
||||
state footerItems = [
|
||||
{
|
||||
"label": "Accessibility",
|
||||
"href": "/accessibility",
|
||||
"value": "accessibility"
|
||||
},
|
||||
{
|
||||
"label": "Privacy",
|
||||
"href": "/privacy",
|
||||
"value": "privacy"
|
||||
}
|
||||
]
|
||||
view { <footer></footer> }
|
||||
}
|
||||
`;
|
||||
const options = { insertSpaces: true, tabSize: 2 };
|
||||
|
||||
assert.equal(formatWrn(source, options), expected);
|
||||
assert.equal(formatWrn(expected, options), expected);
|
||||
});
|
||||
|
||||
test("formats direct structured component props and preserves expression props", () => {
|
||||
const source = `component Demo {
|
||||
view {
|
||||
<Footer items={footerItems} options={{"dense":true,"theme":"public"}} links={[{"label":"Privacy","href":"/privacy"},{"label":"Contact","href":"/contact"}]} />
|
||||
}
|
||||
}
|
||||
`;
|
||||
const expected = `component Demo {
|
||||
view {
|
||||
<Footer
|
||||
items={footerItems}
|
||||
options={{
|
||||
"dense": true,
|
||||
"theme": "public"
|
||||
}}
|
||||
links={[
|
||||
{
|
||||
"label": "Privacy",
|
||||
"href": "/privacy"
|
||||
},
|
||||
{
|
||||
"label": "Contact",
|
||||
"href": "/contact"
|
||||
}
|
||||
]}
|
||||
/>
|
||||
}
|
||||
}
|
||||
`;
|
||||
const options = { insertSpaces: true, tabSize: 2, multilineAttributes: true };
|
||||
|
||||
assert.equal(formatWrn(source, options), expected);
|
||||
assert.equal(formatWrn(expected, options), expected);
|
||||
});
|
||||
|
||||
test("formats public event declarations as individual props members", () => {
|
||||
const source = `component Search {\nprops { value = "" @event search = function @event clear = function }\nview { <input/> }\n}\n`;
|
||||
const formatted = formatWrn(source, { insertSpaces: true, tabSize: 2 });
|
||||
|
||||
Reference in New Issue
Block a user