Add test for Results invalidation

This triggers a crash!
This commit is contained in:
Scott Kyle 2016-04-27 14:01:01 -07:00
parent 0c4dfcb914
commit 4705b6b3a5
1 changed files with 29 additions and 2 deletions

View File

@ -278,5 +278,32 @@ module.exports = BaseTest.extend({
TestCase.assertEqual(objects[0].boolCol, true, 'first element descending for boolCol');
TestCase.assertEqual(objects[1].boolCol, false, 'second element descending for boolCol');
TestCase.assertEqual(objects[2].boolCol, false, 'third element descending for boolCol');
},
testResultsInvalidation: function() {
var realm = new Realm({schema: [schemas.TestObject]});
var testObjects = realm.objects('TestObject');
var filteredObjects = testObjects.filtered('doubleCol > 1');
var sortedObjects = testObjects.sorted('doubleCol');
var snapshotObjects = testObjects.snapshot();
realm.close();
realm = new Realm({
schemaVersion: 1,
schema: [schemas.TestObject, schemas.BasicTypes]
});
[
testObjects,
filteredObjects,
sortedObjects,
snapshotObjects,
].forEach(function(objects) {
TestCase.assertThrows(function() { objects[0]; });
TestCase.assertThrows(function() { objects.filtered('doubleCol < 42'); });
TestCase.assertThrows(function() { objects.sorted('doubleCol', true); });
TestCase.assertThrows(function() { objects.snapshot(); });
});
}
});