diff --git a/test/generator/each-block-keyed/_config.js b/test/generator/each-block-keyed/_config.js new file mode 100644 index 0000000000..094c2f1066 --- /dev/null +++ b/test/generator/each-block-keyed/_config.js @@ -0,0 +1,28 @@ +export default { + data: { + todos: [ + { id: 123, description: 'implement keyed each blocks' }, + { id: 234, description: 'implement client-side hydration' } + ] + }, + + html: '

implement keyed each blocks

implement client-side hydration

', + + test ( assert, component, target ) { + const [ p1, p2 ] = target.querySelectorAll( 'p' ); + + component.set({ + todos: [ + { id: 234, description: 'implement client-side hydration' } + ] + }); + assert.htmlEqual( target.innerHTML, '

implement client-side hydration

' ); + + const [ p3 ] = target.querySelectorAll( 'p' ); + + assert.ok( !target.contains( p1 ), 'first

element should be removed' ); + assert.equal( p2, p3, 'second

element should be retained' ); + + component.teardown(); + } +}; diff --git a/test/generator/each-block-keyed/main.html b/test/generator/each-block-keyed/main.html new file mode 100644 index 0000000000..7d5b90a9f8 --- /dev/null +++ b/test/generator/each-block-keyed/main.html @@ -0,0 +1,3 @@ +{{#each todos as todo @id}} +

{{todo.description}}

+{{/each}}