update tests

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

@ -14,6 +14,7 @@ import {
spaces
} from "../helpers.js";
const main = path.resolve('index.js');
let svelte$;
let svelte;
@ -38,7 +39,9 @@ describe.only("runtime", () => {
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();

@ -1,8 +1,8 @@
export default {
html: '',
test ( assert, component, target, window ) {
test(assert, component, target, window) {
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>
export default {
data() {
return { called: false };
},
import { onmount } from 'svelte';
export let value;
let called = false;
oncreate() {
this.set({ called: true });
}
};
</script>
onmount(() => {
called = true;
});
</script>
<p>{value}</p>
<p>{called}</p>

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

Loading…
Cancel
Save