mirror of https://github.com/sveltejs/svelte
failing test for #561
parent
3a7f7e29c2
commit
b55797666a
@ -0,0 +1,6 @@
|
||||
<div class='modal-background' on:click='destroy()'></div>
|
||||
|
||||
<div class='modal'>
|
||||
{{yield}}
|
||||
<button on:click='destroy()'>close modal</button>
|
||||
</div>
|
@ -0,0 +1,25 @@
|
||||
export default {
|
||||
data: {
|
||||
showModal: true
|
||||
},
|
||||
|
||||
html: `
|
||||
<div class='modal-background'></div>
|
||||
|
||||
<div class='modal'>
|
||||
<h2>Hello!</h2>
|
||||
<button>close modal</button>
|
||||
</div>
|
||||
`,
|
||||
|
||||
test ( assert, component, target, window ) {
|
||||
const button = target.querySelector( 'button' );
|
||||
const click = new window.MouseEvent( 'click' );
|
||||
|
||||
button.dispatchEvent( click );
|
||||
|
||||
assert.htmlEqual( target.innerHTML, `
|
||||
<button>show modal</button>
|
||||
`);
|
||||
}
|
||||
};
|
@ -0,0 +1,15 @@
|
||||
{{#if showModal}}
|
||||
<Modal on:destroy='set({ showModal: false })'>
|
||||
<h2>Hello!</h2>
|
||||
</Modal>
|
||||
{{else}}
|
||||
<button on:click='set({ showModal: true })'>show modal</button>
|
||||
{{/if}}
|
||||
|
||||
<script>
|
||||
import Modal from './Modal.html';
|
||||
|
||||
export default {
|
||||
components: { Modal }
|
||||
};
|
||||
</script>
|
Loading…
Reference in new issue