add some simple tests for Realm.write

This commit is contained in:
Ari Lazier 2016-03-29 09:02:36 -07:00
parent d62f78050e
commit 9d0b890923
1 changed files with 24 additions and 0 deletions

View File

@ -138,6 +138,30 @@ module.exports = BaseTest.extend({
});
},
testRealmWrite: function() {
var realm = new Realm({schema: [schemas.IntPrimary, schemas.AllTypes, schemas.TestObject]});
// exceptions should be propogated
TestCase.assertThrows(function() {
realm.write(function() {
realm.invalid();
});
});
// writes should be possible after caught exception
realm.write(function() {
realm.create('TestObject', {doubleCol: 1});
});
TestCase.assertEqual(1, realm.objects('TestObject').length);
realm.write(function() {
// nested transactions not supported
TestCase.assertThrows(function() {
realm.write(function() {});
});
});
},
testRealmCreate: function() {
var realm = new Realm({schema: [schemas.IntPrimary, schemas.AllTypes, schemas.TestObject]});