release: WRNexusJS 0.5.0
This commit is contained in:
@@ -41,6 +41,45 @@ test("@event (data-on-click) mutates a signal and re-renders", () => {
|
||||
expect(btn.textContent).toBe("2");
|
||||
});
|
||||
|
||||
test("component functions support formatted multiline assignments and ternaries", () => {
|
||||
const behavior = Buffer.from(
|
||||
JSON.stringify({
|
||||
functions: `
|
||||
function increment(event, nextValue) {
|
||||
nextValue =
|
||||
Number(count) +
|
||||
(event.shiftKey ? 10 : 1)
|
||||
count = nextValue
|
||||
}
|
||||
|
||||
function normalize(useMinimum) {
|
||||
count = useMinimum
|
||||
? 0
|
||||
: Number(count)
|
||||
}
|
||||
`,
|
||||
watches: [],
|
||||
lifecycle: {},
|
||||
}),
|
||||
).toString("base64");
|
||||
const win = mount(
|
||||
`<div data-scope="count: 0" data-wrn-behavior="${behavior}">
|
||||
<button id="increment" data-on-click="increment(event)">{count}</button>
|
||||
<button id="normalize" data-on-click="normalize(true)">normalize</button>
|
||||
</div>`,
|
||||
);
|
||||
|
||||
const increment = win.document.getElementById("increment") as unknown as HTMLElement;
|
||||
increment.click();
|
||||
expect(increment.textContent).toBe("1");
|
||||
|
||||
increment.dispatchEvent(new win.MouseEvent("click", { shiftKey: true }) as unknown as Event);
|
||||
expect(increment.textContent).toBe("11");
|
||||
|
||||
(win.document.getElementById("normalize") as unknown as HTMLElement).click();
|
||||
expect(increment.textContent).toBe("0");
|
||||
});
|
||||
|
||||
test("declared component events emit through the generic $emit function", () => {
|
||||
const win = mount(
|
||||
`<div data-scope="" data-wrn-events="complete">
|
||||
@@ -148,6 +187,16 @@ test("expression evaluator: member access, ternary, comparison, calls", () => {
|
||||
expect(win.document.getElementById("c")!.textContent).toBe("3");
|
||||
});
|
||||
|
||||
test("expression evaluator exposes safe primitive conversion globals", () => {
|
||||
const win = mount(
|
||||
`<div data-scope="count: 12">
|
||||
<span data-text="String(count)"></span>
|
||||
</div>`,
|
||||
);
|
||||
|
||||
expect(win.document.querySelector("span")!.textContent).toBe("12");
|
||||
});
|
||||
|
||||
test("logical expressions consume their right-hand side when the result short-circuits", () => {
|
||||
const win = mount(
|
||||
`<div data-scope="leftFalse: false, leftTrue: true">
|
||||
@@ -189,6 +238,20 @@ test("data-show toggles visibility on a reactive expression (tabs pattern)", ()
|
||||
expect(win.document.getElementById("b")!.getAttribute("data-show")).toBe("true");
|
||||
});
|
||||
|
||||
test("reactive data attributes preserve explicit boolean strings", () => {
|
||||
const win = mount(
|
||||
`<div data-scope="ready: true">
|
||||
<section
|
||||
id="carousel-layout"
|
||||
data-show="true"
|
||||
data-wrn-bind-0='["data-show","{ready}"]'
|
||||
>Slides</section>
|
||||
</div>`,
|
||||
);
|
||||
|
||||
expect(win.document.getElementById("carousel-layout")!.getAttribute("data-show")).toBe("true");
|
||||
});
|
||||
|
||||
test("reactive attribute bindings update input and accessibility attributes", () => {
|
||||
const win = mount(
|
||||
`<div data-scope="show: false">
|
||||
|
||||
Reference in New Issue
Block a user