From 95235f2be5ed2a51880ab747ef743cf583a31630 Mon Sep 17 00:00:00 2001 From: haveyaseen Date: Sun, 2 May 2021 16:19:11 +0200 Subject: [PATCH] add test for hydration of nested element with if-block element sibling --- .../element-nested-sibling/_after.html | 4 ++++ .../element-nested-sibling/_before.html | 4 ++++ .../samples/element-nested-sibling/_config.js | 19 +++++++++++++++++++ .../element-nested-sibling/main.svelte | 6 ++++++ .../samples/expression-sibling/_config.js | 10 +++++----- 5 files changed, 38 insertions(+), 5 deletions(-) create mode 100644 test/hydration/samples/element-nested-sibling/_after.html create mode 100644 test/hydration/samples/element-nested-sibling/_before.html create mode 100644 test/hydration/samples/element-nested-sibling/_config.js create mode 100644 test/hydration/samples/element-nested-sibling/main.svelte diff --git a/test/hydration/samples/element-nested-sibling/_after.html b/test/hydration/samples/element-nested-sibling/_after.html new file mode 100644 index 0000000000..d011cf6e38 --- /dev/null +++ b/test/hydration/samples/element-nested-sibling/_after.html @@ -0,0 +1,4 @@ +

+ 1 + 2 +

diff --git a/test/hydration/samples/element-nested-sibling/_before.html b/test/hydration/samples/element-nested-sibling/_before.html new file mode 100644 index 0000000000..d011cf6e38 --- /dev/null +++ b/test/hydration/samples/element-nested-sibling/_before.html @@ -0,0 +1,4 @@ +

+ 1 + 2 +

diff --git a/test/hydration/samples/element-nested-sibling/_config.js b/test/hydration/samples/element-nested-sibling/_config.js new file mode 100644 index 0000000000..8410fc189d --- /dev/null +++ b/test/hydration/samples/element-nested-sibling/_config.js @@ -0,0 +1,19 @@ +export default { + snapshot(target) { + const p = target.querySelector('p'); + + return { + p, + span: p.querySelector('span'), + code: p.querySelector('code') + }; + }, + + test(assert, target, snapshot) { + const p = target.querySelector('p'); + + assert.equal(p, snapshot.p); + assert.equal(p.querySelector('span'), snapshot.span); + assert.equal(p.querySelector('code'), snapshot.code); + } +}; diff --git a/test/hydration/samples/element-nested-sibling/main.svelte b/test/hydration/samples/element-nested-sibling/main.svelte new file mode 100644 index 0000000000..d6e02107e2 --- /dev/null +++ b/test/hydration/samples/element-nested-sibling/main.svelte @@ -0,0 +1,6 @@ +

+ 1 + {#if true} + 2 + {/if} +

diff --git a/test/hydration/samples/expression-sibling/_config.js b/test/hydration/samples/expression-sibling/_config.js index 9cc0554776..c6d3ef3f2f 100644 --- a/test/hydration/samples/expression-sibling/_config.js +++ b/test/hydration/samples/expression-sibling/_config.js @@ -1,19 +1,19 @@ export default { snapshot(target) { - const p = target.querySelector("p"); + const p = target.querySelector('p'); return { p, text: p.childNodes[0], - span: p.querySelector("span"), + span: p.querySelector('span') }; }, test(assert, target, snapshot) { - const p = target.querySelector("p"); + const p = target.querySelector('p'); assert.equal(p, snapshot.p); assert.equal(p.childNodes[0], snapshot.text); - assert.equal(p.querySelector("span"), snapshot.span); - }, + assert.equal(p.querySelector('span'), snapshot.span); + } };