You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
svelte/test/runtime/samples/if-block-else-update/_config.js

47 lines
973 B

export default {
async test({ assert, component, target, window }) {
const [btn1, btn2] = target.querySelectorAll('button');
const clickEvent = new window.MouseEvent('click');
await btn2.dispatchEvent(clickEvent);
assert.htmlEqual(target.innerHTML, `
<button>Toggle foo</button>
<button>Toggle bar</button>
<hr>
foo: false, bar: true
<hr>
bar!
`);
await btn1.dispatchEvent(clickEvent);
assert.htmlEqual(target.innerHTML, `
<button>Toggle foo</button>
<button>Toggle bar</button>
<hr>
foo: true, bar: true
<hr>
foo!
`);
await btn2.dispatchEvent(clickEvent);
assert.htmlEqual(target.innerHTML, `
<button>Toggle foo</button>
<button>Toggle bar</button>
<hr>
foo: true, bar: false
<hr>
foo!
`);
await btn1.dispatchEvent(clickEvent);
assert.htmlEqual(target.innerHTML, `
<button>Toggle foo</button>
<button>Toggle bar</button>
<hr>
foo: false, bar: false
<hr>
`);
}
};