Skip to content

Commit e5e8651

Browse files
committed
Tests for #191
1 parent 850a8ee commit e5e8651

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

test/parserTest.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2426,4 +2426,31 @@ test("Bucket is not inherited", async t => {
24262426
"./test/stubs/bucket-noinherit/index.webc",
24272427
"./test/stubs/bucket-noinherit/component.webc",
24282428
]);
2429+
});
2430+
2431+
test("webc:if should short circuit dynamic attribute evaluation #191 (throws)", async t => {
2432+
let component = new WebC();
2433+
component.setContent(`<div webc:if="true" :test="Promise.reject(new Error('This should not evaluate'))"></div>`);
2434+
2435+
let error = await t.throwsAsync(async () => {
2436+
await component.compile({
2437+
data: {}
2438+
});
2439+
});
2440+
t.is(error.message, `Evaluating a dynamic attribute failed: \`:test="Promise.reject(new Error('This should not evaluate'))"\`.
2441+
Original error message: This should not evaluate`);
2442+
});
2443+
2444+
test("webc:if should short circuit dynamic attribute evaluation #191", async t => {
2445+
let component = new WebC();
2446+
component.setContent(`<div webc:if="false" :test="Promise.reject(new Error('This should not evaluate'))"></div>`);
2447+
2448+
let { html, css, js, components } = await component.compile({
2449+
data: {}
2450+
});
2451+
2452+
t.deepEqual(js, []);
2453+
t.deepEqual(css, []);
2454+
t.deepEqual(components, []);
2455+
t.is(html, ``);
24292456
});

0 commit comments

Comments
 (0)