From 78cb44b1a10df77015c979e4c785c111e65e96a7 Mon Sep 17 00:00:00 2001 From: Ari Lazier Date: Tue, 19 Apr 2016 16:07:24 -0700 Subject: [PATCH] add test for isValid --- tests/js/realm-tests.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/js/realm-tests.js b/tests/js/realm-tests.js index 3e6aec72..ecd130e2 100644 --- a/tests/js/realm-tests.js +++ b/tests/js/realm-tests.js @@ -516,6 +516,22 @@ module.exports = BaseTest.extend({ 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() { var realm = new Realm({schema: [schemas.PersonObject, schemas.DefaultValues, schemas.TestObject]});