|
|
@ -3,14 +3,24 @@ import { test } from '../../test';
|
|
|
|
export default test({
|
|
|
|
export default test({
|
|
|
|
html: `<button>increment</button><p>loading...</p>`,
|
|
|
|
html: `<button>increment</button><p>loading...</p>`,
|
|
|
|
|
|
|
|
|
|
|
|
async test({ assert, target }) {
|
|
|
|
async test({ assert, target, variant, logs }) {
|
|
|
|
|
|
|
|
await new Promise((f) => setTimeout(f, 50));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (variant === 'hydrate') {
|
|
|
|
|
|
|
|
assert.deepEqual(logs, ['aborted', { stale: true }]);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
logs.length = 0;
|
|
|
|
|
|
|
|
|
|
|
|
const [button] = target.querySelectorAll('button');
|
|
|
|
const [button] = target.querySelectorAll('button');
|
|
|
|
|
|
|
|
|
|
|
|
await new Promise((f) => setTimeout(f, 50)); // TODO replace with `tick` once `await` lands
|
|
|
|
await new Promise((f) => setTimeout(f, 50));
|
|
|
|
assert.htmlEqual(target.innerHTML, '<button>increment</button><p>0</p>');
|
|
|
|
assert.htmlEqual(target.innerHTML, '<button>increment</button><p>0</p>');
|
|
|
|
|
|
|
|
|
|
|
|
button.click();
|
|
|
|
button.click();
|
|
|
|
await new Promise((f) => setTimeout(f, 50)); // TODO replace with `tick` once `await` lands
|
|
|
|
await new Promise((f) => setTimeout(f, 50));
|
|
|
|
assert.htmlEqual(target.innerHTML, '<button>increment</button><p>2</p>');
|
|
|
|
assert.htmlEqual(target.innerHTML, '<button>increment</button><p>2</p>');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assert.deepEqual(logs, ['aborted', { stale: true }]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|