let fulfil; export default { props: { promise: new Promise((f) => { fulfil = f; }) }, intro: true, async test({ assert, target, component, raf }) { assert.htmlEqual(target.innerHTML, '
loading...
'); let time = 0; raf.tick(time += 50); assert.htmlEqual(target.innerHTML, 'loading...
'); await fulfil(42); assert.htmlEqual(target.innerHTML, `42
loading...
`); // see the transition 30% complete raf.tick(time += 30); assert.htmlEqual(target.innerHTML, `42
loading...
`); // completely transition in the {:then} block raf.tick(time += 70); assert.htmlEqual(target.innerHTML, `42
`); // update promise #1 component.promise = new Promise((f) => { fulfil = f; }); await Promise.resolve(); assert.htmlEqual(target.innerHTML, `42
loading...
`); raf.tick(time += 100); assert.htmlEqual(target.innerHTML, `loading...
`); await fulfil(43); assert.htmlEqual(target.innerHTML, `loading...
43
`); raf.tick(time += 100); assert.htmlEqual(target.innerHTML, `43
`); // update promise #2 component.promise = new Promise((f) => { fulfil = f; }); await Promise.resolve(); assert.htmlEqual(target.innerHTML, `43
loading...
`); raf.tick(time += 50); assert.htmlEqual(target.innerHTML, `43
loading...
`); await fulfil(44); assert.htmlEqual(target.innerHTML, `43
loading...
44
`); raf.tick(time += 100); assert.htmlEqual(target.innerHTML, `44
`); // update promise #3 - quick succession component.promise = new Promise((f) => { fulfil = f; }); await Promise.resolve(); assert.htmlEqual(target.innerHTML, `44
loading...
`); raf.tick(time += 40); assert.htmlEqual(target.innerHTML, `44
loading...
`); await fulfil(45); assert.htmlEqual(target.innerHTML, `44
loading...
45
`); raf.tick(time += 20); assert.htmlEqual(target.innerHTML, `44
loading...
45
`); component.promise = new Promise((f) => { fulfil = f; }); await Promise.resolve(); assert.htmlEqual(target.innerHTML, `44
loading...
45
loading...
`); raf.tick(time += 10); assert.htmlEqual(target.innerHTML, `44
loading...
45
loading...
`); await fulfil(46); assert.htmlEqual(target.innerHTML, `44
loading...
45
loading...
46
`); raf.tick(time += 10); assert.htmlEqual(target.innerHTML, `44
46
`); raf.tick(time += 20); assert.htmlEqual(target.innerHTML, `46
`); raf.tick(time += 70); assert.htmlEqual(target.innerHTML, `46
`); } };