diff --git a/tests/integration/peek-all-test.js b/tests/integration/peek-all-test.js index c023ee7ee96..21fcba5a23b 100644 --- a/tests/integration/peek-all-test.js +++ b/tests/integration/peek-all-test.js @@ -89,3 +89,25 @@ test("Calling store.peekAll() after creating a record should return correct data assert.equal(get(store.peekAll('person'), 'length'), 1, 'should contain one person'); }); }); + +test("Unloading record that is in a peekAll array", function(assert) { + let allPeople = store.peekAll('person'); + + Ember.run(() => { + store.createRecord('person', { name: "Tomster" }); + store.createRecord('person', { name: "Zoey" }); + }); + + assert.equal(get(store.peekAll('person'), 'length'), 2, 'should contain one person'); + + Ember.run(() => { + allPeople.objectAt(0).unloadRecord(); + + assert.equal(get(allPeople, 'length'), 2, 'Unload does not complete until the end of the loop'); + assert.ok(get(allPeople.objectAt(0), 'name'), 'Tomster', 'Tomster is still the first object until the end of the loop'); + assert.ok(get(allPeople.objectAt(1), 'name'), 'Zoey', 'Zoey is still the sencond object until the end of the loop'); + }); + + assert.equal(get(allPeople, 'length'), 1, 'Unloaded record removed from the array'); + assert.ok(get(allPeople.objectAt(0), 'name'), 'Zoey', 'Zoey is now the first object'); +});