Skip to content

Commit

Permalink
Add tests for {{ inline }} expressions
Browse files Browse the repository at this point in the history
  • Loading branch information
vrugtehagel committed May 11, 2024
1 parent 2406bdc commit 4f2a8d4
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 0 deletions.
13 changes: 13 additions & 0 deletions test/components/template/inline/bo-independence.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
await self.yozo.register('./bo-independence.yz');
const element = document.createElement('greeter-independence');

element.greeting = 'hello';
element.receiver = 'world';
document.body.append(element);
await 'microtask';
assert(element.textContent.trim() == 'hello, world!');

element.greeting = 'hi';
element.receiver = 'earth';
await 'microtask';
assert(element.textContent.trim() == 'hello, earth!');
7 changes: 7 additions & 0 deletions test/components/template/inline/bo-independence.yz
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<title>greeter-independence</title>
<meta attribute="greeting" type="string">
<meta attribute="receiver" type="string">

<template>
{{ self.yozo.monitor.ignore(() => $.greeting) }}, {{ $.receiver }}!
</template>
18 changes: 18 additions & 0 deletions test/components/template/inline/bo-not-when-disconnected.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
await self.yozo.register('./bo-not-when-disconnected.yz');
const element = document.createElement('greeter-not-when-disconnected');

element.greeting = 'hello';
element.receiver = 'world';
document.body.append(element);
await 'microtask';
assert(element.textContent.trim() == 'hello, world!');

element.remove();
element.greeting = 'hi';
element.receiver = 'earth';
await 'microtask';
assert(element.textContent.trim() == 'hello, world!');

document.body.append(element);
await 'microtask';
assert(element.textContent.trim() == 'hi, earth!');
7 changes: 7 additions & 0 deletions test/components/template/inline/bo-not-when-disconnected.yz
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<title>greeter-not-when-disconnected</title>
<meta attribute="greeting" type="string">
<meta attribute="receiver" type="string">

<template>
{{ $.greeting }}, {{ $.receiver }}!
</template>

0 comments on commit 4f2a8d4

Please sign in to comment.