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

test update while yield fragment is torn down, and tweak code for consistency

This commit is contained in:
Rich-Harris 2016-12-04 21:09:06 -05:00
parent 4210c238d4
commit 306a931176
2 changed files with 26 additions and 15 deletions

View File

@ -1,15 +1,15 @@
<p>
{{#if show}}
{{yield}}
{{/if}}
{{#if show}}
{{yield}}
{{/if}}
</p>
<script>
export default {
data(){
return {
show: false
}
}
}
<script>
export default {
data () {
return {
show: false
}
}
};
</script>

View File

@ -1,13 +1,24 @@
export default {
html: '<div><p></p></div>',
test ( assert, component, target ) {
const widget = component.refs.widget;
assert.equal( widget.get( 'show' ), false );
widget.set({show: true});
assert.equal( target.innerHTML, '<div><p>Hello<!--yield--><!--#if show--></p></div>' );
assert.htmlEqual( target.innerHTML, '<div><p>Hello</p></div>' );
component.set({data: 'World'});
assert.equal( target.innerHTML, '<div><p>World<!--yield--><!--#if show--></p></div>' );
assert.htmlEqual( target.innerHTML, '<div><p>World</p></div>' );
widget.set({show: false});
assert.equal( target.innerHTML, '<div><p><!--#if show--></p></div>' );
assert.htmlEqual( target.innerHTML, '<div><p></p></div>' );
component.set({data: 'Goodbye'});
assert.htmlEqual( target.innerHTML, '<div><p></p></div>' );
widget.set({show: true});
assert.htmlEqual( target.innerHTML, '<div><p>Goodbye</p></div>' );
}
}
};