0
0
mirror of https://github.com/sveltejs/svelte.git synced 2024-12-01 17:30:59 +01:00

failing test for #956

This commit is contained in:
Rich Harris 2018-05-05 11:12:48 -04:00
parent 9883fb67da
commit f65d56b027
2 changed files with 54 additions and 0 deletions

View File

@ -0,0 +1,32 @@
let fulfil;
let reject;
let promise = new Promise((f, r) => {
fulfil = f;
reject = r;
});
export default {
data: {
promise
},
test(assert, component, target, window, raf) {
component.set({ visible: true });
let p = target.querySelector('p');
assert.equal(p.className, 'pending');
assert.equal(p.foo, 0);
raf.tick(50);
assert.equal(p.foo, 0);
fulfil(42);
raf.tick(80);
let ps = document.querySelectorAll('p');
assert.equal(p[0].className, 'pending');
assert.equal(p[1].className, 'then');
assert.equal(p[0].foo, 20);
assert.equal(p[1].foo, 30);
},
};

View File

@ -0,0 +1,22 @@
{#await promise}
<p class='pending' transition:foo>loading...</p>
{:then value}
<p class='then' transition:foo>{value}</p>
{:catch error}
<p class='catch' transition:foo>{error.message}</p>
{/await}
<script>
export default {
transitions: {
foo(node, params) {
return {
duration: 100,
tick: t => {
node.foo = t;
}
};
}
}
};
</script>