Skip to content

Commit

Permalink
Added failing test for issue emberjs#5025. unloadRecord leaving a n…
Browse files Browse the repository at this point in the history
…ull item in the filter array.
  • Loading branch information
Wesley Workman committed Jul 26, 2017
1 parent 71dc584 commit 2cdf9c7
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions tests/integration/filter-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -841,3 +841,28 @@ test('destroying filteredRecordArray unregisters models from being filtered', fu

assert.equal(filterFn.summary.called.length, 1, 'expected the filter function not being called anymore');
});

test('unloading records in the filter', function(assert) {
run(() => store.push({ data }));

let people = run(() => {
return store.filter('person', hash => {
if (hash.get('name').match(/Scumbag/)) {
return true;
}
});
});

assert.equal(get(people, 'length'), 3, 'precond - three items in the RecordArray');

run(() => {
people.objectAt(0).unloadRecord();

assert.equal(get(people, 'length'), 3, 'Unload does not complete until the end of the loop');
assert.ok(get(people.objectAt(0), 'name'), 'Scumbag Dale', 'Dale is still the first object until the end of the loop');
});

assert.equal(get(people, 'length'), 2, 'Unloaded record removed from the array');
assert.ok(get(people.objectAt(0), 'name'), 'Scumbag Katz', 'Katz shifted down after the unload');
assert.ok(get(people.objectAt(1), 'name'), 'Scumbag Bryn', 'Bryn shifted down after the unload');
});

0 comments on commit 2cdf9c7

Please sign in to comment.