From 37d5a12094f454997c7e04d5bfbd68b992424ad5 Mon Sep 17 00:00:00 2001 From: Scott Kyle Date: Mon, 12 Oct 2015 02:01:29 -0700 Subject: [PATCH] Add test for calling create() outside transaction --- tests/RealmTests.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/RealmTests.js b/tests/RealmTests.js index 760ea37b..3c7b6a21 100644 --- a/tests/RealmTests.js +++ b/tests/RealmTests.js @@ -73,6 +73,11 @@ var RealmTests = { testRealmCreate: function() { var realm = new Realm({schema: [IntPrimaryObjectSchema, AllTypesObjectSchema, TestObjectSchema]}); + + TestCase.assertThrows(function() { + realm.create('TestObject', [1]); + }, 'can only create inside a write transaction'); + realm.write(function() { realm.create('TestObject', [1]); realm.create('TestObject', {'doubleCol': 2}); @@ -171,7 +176,7 @@ var RealmTests = { var objects = realm.objects('TestObject'); TestCase.assertThrows(function() { realm.delete(objects[0]); - }, "can only delete in a write transaction"); + }, 'can only delete in a write transaction'); realm.write(function() { TestCase.assertThrows(function() { @@ -208,7 +213,7 @@ var RealmTests = { TestCase.assertThrows(function() { realm.deleteAll(); - }); + }, 'can only deleteAll in a write transaction'); realm.write(function() { realm.deleteAll();