Tabs -> Spaces in ObjectTests.js

This commit is contained in:
Scott Kyle 2015-10-12 01:59:34 -07:00
parent a670961b13
commit 48c9336526
1 changed files with 52 additions and 52 deletions

View File

@ -20,67 +20,67 @@
var ObjectTests = { var ObjectTests = {
testBasicTypesPropertyGetters: function() { testBasicTypesPropertyGetters: function() {
var basicTypesValues = [true, 1, 1.1, 1.11, 'string', new Date(1), 'DATA']; var basicTypesValues = [true, 1, 1.1, 1.11, 'string', new Date(1), 'DATA'];
var realm = new Realm({schema: [BasicTypesObjectSchema]}); var realm = new Realm({schema: [BasicTypesObjectSchema]});
var object = null; var object = null;
realm.write(function() { realm.write(function() {
object = realm.create('BasicTypesObject', basicTypesValues); object = realm.create('BasicTypesObject', basicTypesValues);
}); });
for (var i = 0; i < BasicTypesObjectSchema.properties.length; i++) { for (var i = 0; i < BasicTypesObjectSchema.properties.length; i++) {
var prop = BasicTypesObjectSchema.properties[i]; var prop = BasicTypesObjectSchema.properties[i];
if (prop.type == Realm.Types.FLOAT) { if (prop.type == Realm.Types.FLOAT) {
TestCase.assertEqualWithTolerance(object[prop.name], basicTypesValues[i], 0.000001); TestCase.assertEqualWithTolerance(object[prop.name], basicTypesValues[i], 0.000001);
} }
else if (prop.type == Realm.Types.DATE) { else if (prop.type == Realm.Types.DATE) {
TestCase.assertEqual(object[prop.name].getTime(), basicTypesValues[i].getTime()); TestCase.assertEqual(object[prop.name].getTime(), basicTypesValues[i].getTime());
} }
else { else {
TestCase.assertEqual(object[prop.name], basicTypesValues[i]); TestCase.assertEqual(object[prop.name], basicTypesValues[i]);
} }
} }
}, },
testBasicTypesPropertySetters: function() { testBasicTypesPropertySetters: function() {
var basicTypesValues = [true, 1, 1.1, 1.11, 'string', new Date(1), 'DATA']; var basicTypesValues = [true, 1, 1.1, 1.11, 'string', new Date(1), 'DATA'];
var realm = new Realm({schema: [BasicTypesObjectSchema]}); var realm = new Realm({schema: [BasicTypesObjectSchema]});
var obj = null; var obj = null;
realm.write(function() { realm.write(function() {
obj = realm.create('BasicTypesObject', basicTypesValues); obj = realm.create('BasicTypesObject', basicTypesValues);
obj.boolCol = false; obj.boolCol = false;
obj.intCol = 2; obj.intCol = 2;
obj.floatCol = 2.2; obj.floatCol = 2.2;
obj.doubleCol = 2.22; obj.doubleCol = 2.22;
obj.stringCol = 'STRING'; obj.stringCol = 'STRING';
obj.dateCol = new Date(2); obj.dateCol = new Date(2);
obj.dataCol = 'b'; obj.dataCol = 'b';
}); });
TestCase.assertEqual(obj.boolCol, false, 'wrong bool value'); TestCase.assertEqual(obj.boolCol, false, 'wrong bool value');
TestCase.assertEqual(obj.intCol, 2, 'wrong int value'); TestCase.assertEqual(obj.intCol, 2, 'wrong int value');
TestCase.assertEqualWithTolerance(obj.floatCol, 2.2, 0.000001, 'wrong float value'); TestCase.assertEqualWithTolerance(obj.floatCol, 2.2, 0.000001, 'wrong float value');
TestCase.assertEqual(obj.doubleCol, 2.22, 'wrong double value'); TestCase.assertEqual(obj.doubleCol, 2.22, 'wrong double value');
TestCase.assertEqual(obj.stringCol, 'STRING', 'wrong string value'); TestCase.assertEqual(obj.stringCol, 'STRING', 'wrong string value');
TestCase.assertEqual(obj.dateCol.getTime(), 2, 'wrong date value'); TestCase.assertEqual(obj.dateCol.getTime(), 2, 'wrong date value');
TestCase.assertEqual(obj.dataCol, 'b', 'wrong data value'); TestCase.assertEqual(obj.dataCol, 'b', 'wrong data value');
}, },
testLinkTypesPropertyGetters: function() { testLinkTypesPropertyGetters: function() {
var realm = new Realm({schema: [LinkTypesObjectSchema, TestObjectSchema]}); var realm = new Realm({schema: [LinkTypesObjectSchema, TestObjectSchema]});
var obj = null; var obj = null;
realm.write(function() { realm.write(function() {
obj = realm.create('LinkTypesObject', [[1], null, [[3]]]); obj = realm.create('LinkTypesObject', [[1], null, [[3]]]);
}); });
var objVal = obj.objectCol; var objVal = obj.objectCol;
TestCase.assertEqual(typeof objVal, 'object'); TestCase.assertEqual(typeof objVal, 'object');
TestCase.assertNotEqual(objVal, null); TestCase.assertNotEqual(objVal, null);
TestCase.assertEqual(objVal.doubleCol, 1); TestCase.assertEqual(objVal.doubleCol, 1);
TestCase.assertEqual(obj.objectCol1, null); TestCase.assertEqual(obj.objectCol1, null);
var arrayVal = obj.arrayCol; var arrayVal = obj.arrayCol;
TestCase.assertEqual(typeof arrayVal, 'object'); TestCase.assertEqual(typeof arrayVal, 'object');
TestCase.assertNotEqual(arrayVal, null); TestCase.assertNotEqual(arrayVal, null);
TestCase.assertEqual(arrayVal.length, 1); TestCase.assertEqual(arrayVal.length, 1);
TestCase.assertEqual(arrayVal[0].doubleCol, 3); TestCase.assertEqual(arrayVal[0].doubleCol, 3);
}, },
testLinkTypesPropertySetters: function() { testLinkTypesPropertySetters: function() {
var realm = new Realm({schema: [LinkTypesObjectSchema, TestObjectSchema]}); var realm = new Realm({schema: [LinkTypesObjectSchema, TestObjectSchema]});