update tests

pull/1864/head
Rich Harris 7 years ago
parent 48c705aea1
commit 6a752a5675

@ -14,6 +14,7 @@ import {
spaces spaces
} from "../helpers.js"; } from "../helpers.js";
const main = path.resolve('index.js');
let svelte$; let svelte$;
let svelte; let svelte;
@ -38,7 +39,9 @@ describe.only("runtime", () => {
const { js } = compile(fs.readFileSync(filename, "utf-8"), options); const { js } = compile(fs.readFileSync(filename, "utf-8"), options);
return module._compile(js.code, filename); const code = js.code.replace(/require\("svelte"\)/g, `require("${main}")`);
return module._compile(code, filename);
}; };
return setupHtmlEqual(); return setupHtmlEqual();

@ -3,6 +3,6 @@ export default {
test(assert, component, target, window) { test(assert, component, target, window) {
component.visible = true; component.visible = true;
assert.equal( component.refs.input, window.document.activeElement ); assert.equal(target.querySelector('input'), window.document.activeElement);
} }
}; };

@ -1,14 +1,13 @@
<p>{value}</p>
<p>{called}</p>
<script> <script>
export default { import { onmount } from 'svelte';
data() {
return { called: false }; export let value;
}, let called = false;
oncreate() { onmount(() => {
this.set({ called: true }); called = true;
} });
};
</script> </script>
<p>{value}</p>
<p>{called}</p>

@ -16,17 +16,17 @@ export default {
fulfil(42); fulfil(42);
return thePromise return thePromise
.then(() => { .then(async () => {
assert.htmlEqual(target.innerHTML, ` assert.htmlEqual(target.innerHTML, `
<button>click me</button> <button>click me</button>
`); `);
const { button } = component.refs; const { button } = component;
const click = new window.MouseEvent('click'); const click = new window.MouseEvent('click');
button.dispatchEvent(click); button.dispatchEvent(click);
assert.equal(component.get().clicked, 42); assert.equal(component.clicked, 42);
thePromise = Promise.resolve(43); thePromise = Promise.resolve(43);
component.thePromise = thePromise; component.thePromise = thePromise;
@ -34,12 +34,12 @@ export default {
return thePromise; return thePromise;
}) })
.then(() => { .then(() => {
const { button } = component.refs; const { button } = component;
const click = new window.MouseEvent('click'); const click = new window.MouseEvent('click');
button.dispatchEvent(click); button.dispatchEvent(click);
assert.equal(component.get().clicked, 43); assert.equal(component.clicked, 43);
}); });
} }
}; };

@ -1,3 +1,9 @@
<script>
export let button;
export let thePromise;
export let clicked;
</script>
{#await thePromise} {#await thePromise}
<p>loading...</p> <p>loading...</p>
{:then theValue} {:then theValue}

Loading…
Cancel
Save