From 4f2a8d44559dd59a00ed1296c49451bd3f1c69ff Mon Sep 17 00:00:00 2001 From: vrugtehagel Date: Sat, 11 May 2024 22:29:40 +0200 Subject: [PATCH] Add tests for {{ inline }} expressions --- .../template/inline/bo-independence.js | 13 +++++++++++++ .../template/inline/bo-independence.yz | 7 +++++++ .../inline/bo-not-when-disconnected.js | 18 ++++++++++++++++++ .../inline/bo-not-when-disconnected.yz | 7 +++++++ 4 files changed, 45 insertions(+) create mode 100644 test/components/template/inline/bo-independence.js create mode 100644 test/components/template/inline/bo-independence.yz create mode 100644 test/components/template/inline/bo-not-when-disconnected.js create mode 100644 test/components/template/inline/bo-not-when-disconnected.yz diff --git a/test/components/template/inline/bo-independence.js b/test/components/template/inline/bo-independence.js new file mode 100644 index 0000000..28aab37 --- /dev/null +++ b/test/components/template/inline/bo-independence.js @@ -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!'); diff --git a/test/components/template/inline/bo-independence.yz b/test/components/template/inline/bo-independence.yz new file mode 100644 index 0000000..a45f922 --- /dev/null +++ b/test/components/template/inline/bo-independence.yz @@ -0,0 +1,7 @@ +greeter-independence + + + + diff --git a/test/components/template/inline/bo-not-when-disconnected.js b/test/components/template/inline/bo-not-when-disconnected.js new file mode 100644 index 0000000..359bf68 --- /dev/null +++ b/test/components/template/inline/bo-not-when-disconnected.js @@ -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!'); diff --git a/test/components/template/inline/bo-not-when-disconnected.yz b/test/components/template/inline/bo-not-when-disconnected.yz new file mode 100644 index 0000000..2124a24 --- /dev/null +++ b/test/components/template/inline/bo-not-when-disconnected.yz @@ -0,0 +1,7 @@ +greeter-not-when-disconnected + + + +