mirror of
https://github.com/status-im/realm-js.git
synced 2025-01-11 14:54:33 +00:00
Add test for calling create() outside transaction
This commit is contained in:
parent
48c9336526
commit
37d5a12094
@ -73,6 +73,11 @@ var RealmTests = {
|
|||||||
|
|
||||||
testRealmCreate: function() {
|
testRealmCreate: function() {
|
||||||
var realm = new Realm({schema: [IntPrimaryObjectSchema, AllTypesObjectSchema, TestObjectSchema]});
|
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.write(function() {
|
||||||
realm.create('TestObject', [1]);
|
realm.create('TestObject', [1]);
|
||||||
realm.create('TestObject', {'doubleCol': 2});
|
realm.create('TestObject', {'doubleCol': 2});
|
||||||
@ -171,7 +176,7 @@ var RealmTests = {
|
|||||||
var objects = realm.objects('TestObject');
|
var objects = realm.objects('TestObject');
|
||||||
TestCase.assertThrows(function() {
|
TestCase.assertThrows(function() {
|
||||||
realm.delete(objects[0]);
|
realm.delete(objects[0]);
|
||||||
}, "can only delete in a write transaction");
|
}, 'can only delete in a write transaction');
|
||||||
|
|
||||||
realm.write(function() {
|
realm.write(function() {
|
||||||
TestCase.assertThrows(function() {
|
TestCase.assertThrows(function() {
|
||||||
@ -208,7 +213,7 @@ var RealmTests = {
|
|||||||
|
|
||||||
TestCase.assertThrows(function() {
|
TestCase.assertThrows(function() {
|
||||||
realm.deleteAll();
|
realm.deleteAll();
|
||||||
});
|
}, 'can only deleteAll in a write transaction');
|
||||||
|
|
||||||
realm.write(function() {
|
realm.write(function() {
|
||||||
realm.deleteAll();
|
realm.deleteAll();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user