Skip to content

Commit d0d9dff

Browse files
author
Alfred Ringstad
committed
Add test for passing props and fix test vars
1 parent e16b36d commit d0d9dff

File tree

10 files changed

+37
-15
lines changed

10 files changed

+37
-15
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
export default {
2-
html: '<div>Test</div>'
2+
html: '<div>Foo</div>'
33
};
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<svelte:element tag={"div"}>Test</svelte:element>
1+
<svelte:element tag={"div"}>Foo</svelte:element>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
let clicked = false;
2+
3+
export default {
4+
props: {
5+
tag: 'div',
6+
onClick: () => clicked = true
7+
},
8+
html: '<div style="display: inline;">Foo</div>',
9+
10+
async test({ assert, target, window }) {
11+
const div = target.querySelector('div');
12+
await div.dispatchEvent(new window.MouseEvent('click'));
13+
14+
assert.equal(clicked, true);
15+
}
16+
};
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<script>
2+
const tag = "div";
3+
export let onClick;
4+
</script>
5+
6+
<svelte:element tag={tag} style="display: inline;" on:click={onClick}>Foo</svelte:element>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
export default {
2-
html: '<div>Test</div>'
2+
html: '<div>Foo</div>'
33
};
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<svelte:element tag="div">Test</svelte:element>
1+
<svelte:element tag="div">Foo</svelte:element>
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
export default {
22
props: {
33
tag: 'div',
4-
text: 'Test'
4+
text: 'Foo'
55
},
6-
html: '<div>Test</div>',
6+
html: '<div>Foo</div>',
77

88
test({ assert, component, target }) {
99
const div = target.firstChild;
10-
component.text = 'Wow';
10+
component.text = 'Bar';
1111

1212
assert.htmlEqual(
1313
target.innerHTML,
1414
`
15-
<div>Wow</div>
15+
<div>Bar</div>
1616
`
1717
);
1818

19-
// Svelte is reusing element
19+
// Re-use element since tag has not changed
2020
assert.equal(div, target.firstChild);
2121
}
2222
};
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<script>
22
const tag = "div";
3-
export let text = "Test";
3+
export let text = "Foo";
44
</script>
55

66
<svelte:element tag={tag}>{text}</svelte:element>

test/runtime/samples/dynamic-element-variable/_config.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
export default {
22
props: {
33
tag: 'div',
4-
text: 'Test'
4+
text: 'Foo'
55
},
6-
html: '<div>Test</div>',
6+
html: '<div>Foo</div>',
77

88
test({ assert, component, target }) {
99
const div = target.firstChild;
1010
component.tag = 'h1';
11-
component.text = 'Wow';
11+
component.text = 'Bar';
1212

1313
assert.htmlEqual(target.innerHTML, `
14-
<h1>Wow</h1>
14+
<h1>Bar</h1>
1515
`);
1616

1717
const h1 = target.firstChild;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<script>
22
export let tag = "div";
3-
export let text = "Test";
3+
export let text = "Foo";
44
</script>
55

66
<svelte:element tag={tag}>{text}</svelte:element>

0 commit comments

Comments
 (0)