Skip to content

Commit

Permalink
Add tests for <meta method>
Browse files Browse the repository at this point in the history
  • Loading branch information
vrugtehagel committed May 17, 2024
1 parent 7593e87 commit e893ea7
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 0 deletions.
11 changes: 11 additions & 0 deletions test/components/meta/method/bo-arguments.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
await self.yozo.register('./bo-arguments.yz');
const element = document.createElement('reverser-arguments');
document.body.append(element);

element.textContent = 'hello world';

assert(element.textContent == 'hello world');

element.reverse('before - ', ' - after');

assert(element.textContent == 'before - dlrow olleh - after');
9 changes: 9 additions & 0 deletions test/components/meta/method/bo-arguments.yz
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<title>reverser-arguments</title>
<meta method="reverse">
<script>
$.reverse = (before, after) => {
const text = this.textContent;
const reversed = [...text].reverse().join('');
this.textContent = `${before}${reversed}${after}`;
};
</script>
11 changes: 11 additions & 0 deletions test/components/meta/method/bo-binding.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
await self.yozo.register('./bo-binding.yz');
const element = document.createElement('reverser-binding');
document.body.append(element);

element.textContent = 'hello world';

assert(element.textContent == 'hello world');

element.reverse();

assert(element.textContent == 'dlrow olleh');
8 changes: 8 additions & 0 deletions test/components/meta/method/bo-binding.yz
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<title>reverser-binding</title>
<meta method="reverse">
<script>
$.reverse = () => {
const text = this.textContent;
this.textContent = [...text].reverse().join('');
};
</script>
17 changes: 17 additions & 0 deletions test/components/meta/method/bo-readonly.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
await self.yozo.register('./bo-readonly.yz');
const element = document.createElement('reverser-readonly');
document.body.append(element);
element.textContent = 'hello world';

let threw = false;
try {
element.reverse = () => element.textContent = 'foo';
} catch {
threw = true;
}

assert(threw);

element.reverse();

assert(element.textContent == 'dlrow olleh');
8 changes: 8 additions & 0 deletions test/components/meta/method/bo-readonly.yz
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<title>reverser-readonly</title>
<meta method="reverse">
<script>
$.reverse = () => {
const text = this.textContent;
this.textContent = [...text].reverse().join('');
};
</script>

0 comments on commit e893ea7

Please sign in to comment.