diff --git a/tests/integration/mutation-test.js b/tests/integration/mutation-test.js index 983fd0bf..dc952183 100644 --- a/tests/integration/mutation-test.js +++ b/tests/integration/mutation-test.js @@ -1,8 +1,10 @@ -import { module } from 'qunit'; +import { module,test } from 'qunit'; import { setupRenderingTest } from 'ember-qunit'; +import hbs from 'htmlbars-inline-precompile'; import { find, findAll, + settled } from '@ember/test-helpers'; import scrollTo from '../helpers/scroll-to'; @@ -265,4 +267,51 @@ module('vertical-collection', 'Integration | Mutation Tests', function(hooks) { assert.equal(find('.vertical-item:last-of-type').textContent.trim(), '4 4', 'last item rendered correctly before move'); } ); + + test('Collection updates correctly when a key is given', async function(assert) { + assert.expect(5); + + const initialItems = [ + { id: 'item-1', props: [{ name: 'prop', value: 'v1'}]}, + { id: 'item-2', props: [{ name: 'prop', value: 'v2'}]}, + ]; + + const updatedItems = [ + { id: 'item-1', props: [{ name: 'prop', value: 'v1'}]}, + { id: 'item-2', props: [{ name: 'prop', value: 'v2-updated'}]}, + { id: 'item-3', props: [{ name: 'prop', value: 'v3-added'}]}, + ]; + + this.set('items', initialItems); + + this.render(hbs` +