make it a runtime test, not a js one

pull/2237/head
Richard Harris 6 years ago
parent 57897d468e
commit 0535b3340c

@ -1,97 +0,0 @@
/* generated by Svelte vX.Y.Z */
import { SvelteComponent as SvelteComponent_1, createComment, createElement, destroyEach, detachNode, init, insert, noop, safe_not_equal, setAttribute } from "svelte/internal";
function get_each_context(ctx, list, i) {
const child_ctx = Object.create(ctx);
child_ctx.item = list[i];
return child_ctx;
}
// (1:0) {#each Array(1) as item}
function create_each_block(ctx) {
var boo;
function func() {
return ctx.func(ctx);
}
return {
c() {
boo = createElement("boo");
setAttribute(boo, "cb", func);
},
m(target, anchor) {
insert(target, boo, anchor);
},
p(changed, new_ctx) {
ctx = new_ctx;
},
d(detach) {
if (detach) {
detachNode(boo);
}
}
};
}
function create_fragment(ctx) {
var each_anchor;
var each_value = Array(1);
var each_blocks = [];
for (var i = 0; i < each_value.length; i += 1) {
each_blocks[i] = create_each_block(get_each_context(ctx, each_value, i));
}
return {
c() {
for (var i = 0; i < each_blocks.length; i += 1) {
each_blocks[i].c();
}
each_anchor = createComment();
},
m(target, anchor) {
for (var i = 0; i < each_blocks.length; i += 1) {
each_blocks[i].m(target, anchor);
}
insert(target, each_anchor, anchor);
},
p: noop,
i: noop,
o: noop,
d(detach) {
destroyEach(each_blocks, detach);
if (detach) {
detachNode(each_anchor);
}
}
};
}
function instance($$self) {
function func({ item }) {
return item;
}
return { func };
}
class SvelteComponent extends SvelteComponent_1 {
constructor(options) {
super();
init(this, options, instance, create_fragment, safe_not_equal);
}
}
export default SvelteComponent;

@ -1,3 +0,0 @@
{#each Array(1) as item}
<boo cb="{() => item}" />
{/each}

@ -0,0 +1,7 @@
<script>
export let handleClick;
</script>
<button on:click={handleClick}>
click me
</button>

@ -0,0 +1,12 @@
export default {
html: `<button>click me</button>`,
async test({ assert, component, target, window }) {
const button = target.querySelector('button');
const click = new window.MouseEvent('click');
await button.dispatchEvent(click);
assert.equal(component.clicked, 'x');
}
};

@ -0,0 +1,9 @@
<script>
import Widget from './Widget.svelte';
export let clicked;
</script>
{#each ['x'] as letter}
<Widget handleClick="{() => clicked = letter}"/>
{/each}
Loading…
Cancel
Save