add test for isValid

This commit is contained in:
Ari Lazier 2016-04-19 16:07:24 -07:00
parent 3509caedd5
commit 78cb44b1a1
1 changed files with 16 additions and 0 deletions

View File

@ -516,6 +516,22 @@ module.exports = BaseTest.extend({
TestCase.assertEqual(realm.objects('IntPrimaryObject').length, 0); TestCase.assertEqual(realm.objects('IntPrimaryObject').length, 0);
}, },
testIsValid: function() {
var realm = new Realm({schema: [schemas.TestObject]});
var obj;
realm.write(function() {
obj = realm.create('TestObject', {doubleCol: 1});
TestCase.assertEqual(realm.isValid(obj), true);
realm.delete(obj);
TestCase.assertEqual(realm.isValid(obj), false);
});
TestCase.assertEqual(realm.isValid(obj), false);
TestCase.assertThrows(function() {
obj.doubleCol;
});
},
testRealmObjects: function() { testRealmObjects: function() {
var realm = new Realm({schema: [schemas.PersonObject, schemas.DefaultValues, schemas.TestObject]}); var realm = new Realm({schema: [schemas.PersonObject, schemas.DefaultValues, schemas.TestObject]});