From e9aa46a8f7cc7c1d54587f57d78b9620c8eedd20 Mon Sep 17 00:00:00 2001 From: Ari Lazier Date: Fri, 4 Sep 2015 12:28:57 -0700 Subject: [PATCH] more tests for partial update --- tests/RealmTests.js | 29 ++++++++++++++++++++++------- tests/TestObjects.js | 8 +++++++- 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/tests/RealmTests.js b/tests/RealmTests.js index 6ffd3041..71e0e9c7 100644 --- a/tests/RealmTests.js +++ b/tests/RealmTests.js @@ -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'); + realm.create('StringPrimaryObject', { primaryCol: '0' }, true); + 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'); }); }, diff --git a/tests/TestObjects.js b/tests/TestObjects.js index 912ccf22..d52bfb53 100644 --- a/tests/TestObjects.js +++ b/tests/TestObjects.js @@ -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}, ] }; \ No newline at end of file