Skip to content

Commit

Permalink
Add failing test for null hydration
Browse files Browse the repository at this point in the history
  • Loading branch information
eps1lon committed Aug 8, 2019
1 parent 2ef004e commit 12c667f
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 0 deletions.
2 changes: 2 additions & 0 deletions test/hydration/samples/dynamic-text-nil/_after.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<p></p>
<p>undefined</p>
2 changes: 2 additions & 0 deletions test/hydration/samples/dynamic-text-nil/_before.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<p>null</p>
<p>undefined</p>
21 changes: 21 additions & 0 deletions test/hydration/samples/dynamic-text-nil/_config.js
Original file line number Diff line number Diff line change
@@ -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);
},
};
7 changes: 7 additions & 0 deletions test/hydration/samples/dynamic-text-nil/main.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<script>
let maybeNull = null;
let maybeUndefined = undefined;
</script>

<p>{maybeNull}</p>
<p>{maybeUndefined}</p>

0 comments on commit 12c667f

Please sign in to comment.