From 12c667f8985d58013bfe87ecf6979b4843c3ad87 Mon Sep 17 00:00:00 2001 From: Sebastian Silbermann Date: Thu, 8 Aug 2019 13:42:28 +0200 Subject: [PATCH] Add failing test for null hydration --- .../samples/dynamic-text-nil/_after.html | 2 ++ .../samples/dynamic-text-nil/_before.html | 2 ++ .../samples/dynamic-text-nil/_config.js | 21 +++++++++++++++++++ .../samples/dynamic-text-nil/main.svelte | 7 +++++++ 4 files changed, 32 insertions(+) create mode 100644 test/hydration/samples/dynamic-text-nil/_after.html create mode 100644 test/hydration/samples/dynamic-text-nil/_before.html create mode 100644 test/hydration/samples/dynamic-text-nil/_config.js create mode 100644 test/hydration/samples/dynamic-text-nil/main.svelte diff --git a/test/hydration/samples/dynamic-text-nil/_after.html b/test/hydration/samples/dynamic-text-nil/_after.html new file mode 100644 index 0000000000..817637990b --- /dev/null +++ b/test/hydration/samples/dynamic-text-nil/_after.html @@ -0,0 +1,2 @@ +

+

undefined

diff --git a/test/hydration/samples/dynamic-text-nil/_before.html b/test/hydration/samples/dynamic-text-nil/_before.html new file mode 100644 index 0000000000..b20e4a8074 --- /dev/null +++ b/test/hydration/samples/dynamic-text-nil/_before.html @@ -0,0 +1,2 @@ +

null

+

undefined

diff --git a/test/hydration/samples/dynamic-text-nil/_config.js b/test/hydration/samples/dynamic-text-nil/_config.js new file mode 100644 index 0000000000..0f98a704b0 --- /dev/null +++ b/test/hydration/samples/dynamic-text-nil/_config.js @@ -0,0 +1,21 @@ +export default { + props: {}, + + snapshot(target) { + const nullText = target.querySelectorAll('p')[0].textContent; + const undefinedText = target.querySelectorAll('p')[1].textContent; + + return { + nullText, + undefinedText, + }; + }, + + test(assert, target, snapshot) { + const nullText = target.querySelectorAll('p')[0].textContent; + const undefinedText = target.querySelectorAll('p')[1].textContent; + + assert.equal(nullText, snapshot.nullText); + assert.equal(undefinedText, snapshot.undefinedText); + }, +}; diff --git a/test/hydration/samples/dynamic-text-nil/main.svelte b/test/hydration/samples/dynamic-text-nil/main.svelte new file mode 100644 index 0000000000..853faa635c --- /dev/null +++ b/test/hydration/samples/dynamic-text-nil/main.svelte @@ -0,0 +1,7 @@ + + +

{maybeNull}

+

{maybeUndefined}