From 2eb64f116a1ee052eccf4722a5d9bfd6f180bb56 Mon Sep 17 00:00:00 2001 From: Wesley Workman Date: Mon, 28 Aug 2017 16:44:48 -0400 Subject: [PATCH] Added failing test for #5111. --- tests/integration/peek-all-test.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tests/integration/peek-all-test.js b/tests/integration/peek-all-test.js index 2f836487f2c..694bbe79f44 100644 --- a/tests/integration/peek-all-test.js +++ b/tests/integration/peek-all-test.js @@ -90,3 +90,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'); +});