Skip to content

Commit

Permalink
Added failing test for #5111.
Browse files Browse the repository at this point in the history
  • Loading branch information
Wesley Workman committed Dec 1, 2017
1 parent 19e1b1b commit aa0d0bf
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tests/integration/peek-all-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');

run(() => {
store.createRecord('person', { name: "Tomster" });
store.createRecord('person', { name: "Zoey" });
});

assert.equal(get(store.peekAll('person'), 'length'), 2, 'should contain one person');

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');
});

0 comments on commit aa0d0bf

Please sign in to comment.