mirror of
https://github.com/status-im/realm-js.git
synced 2025-02-04 18:54:38 +00:00
Merge pull request #1450 from realm/bug/deleting-last-object
Adding test to illustrate deleting objects while iterating
This commit is contained in:
commit
e95d5423db
@ -627,6 +627,26 @@ module.exports = {
|
||||
TestCase.assertEqual(calls, 2);
|
||||
},
|
||||
|
||||
testIteratorDeleteObjects: function() {
|
||||
var realm = new Realm({ schema: [ schemas.TestObject ]});
|
||||
realm.write(() => {
|
||||
realm.create('TestObject', { doubleCol: 2 });
|
||||
realm.create('TestObject', { doubleCol: 3 });
|
||||
});
|
||||
|
||||
var results = realm.objects('TestObject');
|
||||
TestCase.assertEqual(results.length, 2);
|
||||
var calls = 0;
|
||||
for(let obj of results) {
|
||||
realm.write(() => {
|
||||
realm.delete(obj);
|
||||
calls++;
|
||||
});
|
||||
}
|
||||
TestCase.assertEqual(calls, 2);
|
||||
TestCase.assertEqual(realm.objects('TestObject').length, 0);
|
||||
},
|
||||
|
||||
testResultsUpdate: function() {
|
||||
const N = 5;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user