Add test for calling create() outside transaction

This commit is contained in:
Scott Kyle 2015-10-12 02:01:29 -07:00
parent 48c9336526
commit 37d5a12094
1 changed files with 7 additions and 2 deletions

View File

@ -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();