more tests for partial update

This commit is contained in:
Ari Lazier 2015-09-04 12:28:57 -07:00
parent 10a04da42c
commit e9aa46a8f7
2 changed files with 29 additions and 8 deletions

View File

@ -104,21 +104,36 @@ var RealmTests = {
});
realm.write(function() {
var obj0 = realm.create('StringPrimaryObject', ['0', 'val0']);
var obj0 = realm.create('StringPrimaryObject', ['0', true, 1, 1.1, 1.11, '1', new Date(1), '1']);
TestCase.assertThrows(function() {
realm.create('StringPrimaryObject', ['0', 'val0']);
realm.create('StringPrimaryObject', ['0', true, 1, 1.1, 1.11, '1', new Date(1), '1']);
});
realm.create('StringPrimaryObject', ['1', 'val1'], true);
realm.create('StringPrimaryObject', ['1', true, 2, 2.2, 2.11, '2', new Date(2), '2'], true);
var objects = realm.objects('StringPrimaryObject');
TestCase.assertEqual(objects.length, 2);
realm.create('StringPrimaryObject', ['0', 'newVal0'], true);
TestCase.assertEqual(obj0.valueCol, 'newVal0');
realm.create('StringPrimaryObject', ['0', false, 2, 2.2, 2.22, '2', new Date(2), '2'], true);
TestCase.assertEqual(objects.length, 2);
TestCase.assertEqual(obj0.stringCol, '2');
TestCase.assertEqual(obj0.boolCol, false);
TestCase.assertEqual(obj0.intCol, 2);
TestCase.assertEqualWithTolerance(obj0.floatCol, 2.2, 0.000001);
TestCase.assertEqual(obj0.doubleCol, 2.22);
TestCase.assertEqual(obj0.dateCol.getTime(), 2);
TestCase.assertEqual(obj0.dataCol, '2');
realm.create('StringPrimaryObject', { primaryCol: '0' }, true);
TestCase.assertEqual(obj0.valueCol, 'newVal0');
TestCase.assertEqual(obj0.stringCol, '2');
realm.create('StringPrimaryObject', { primaryCol: '0', stringCol: '3' }, true);
TestCase.assertEqual(obj0.stringCol, '3');
TestCase.assertEqual(obj0.boolCol, false);
TestCase.assertEqual(obj0.intCol, 2);
TestCase.assertEqualWithTolerance(obj0.floatCol, 2.2, 0.000001);
TestCase.assertEqual(obj0.doubleCol, 2.22);
TestCase.assertEqual(obj0.dateCol.getTime(), 2);
TestCase.assertEqual(obj0.dataCol, '2');
});
},

View File

@ -73,6 +73,12 @@ var StringPrimaryObjectSchema = {
primaryKey: 'primaryCol',
properties: [
{name: 'primaryCol', type: RealmType.String},
{name: 'valueCol', type: RealmType.String},
{name: 'boolCol', type: RealmType.Bool},
{name: 'intCol', type: RealmType.Int},
{name: 'floatCol', type: RealmType.Float},
{name: 'doubleCol', type: RealmType.Double},
{name: 'stringCol', type: RealmType.String},
{name: 'dateCol', type: RealmType.Date},
{name: 'dataCol', type: RealmType.Data},
]
};