[Tests] Stop using Realm.Types
This commit is contained in:
parent
b08db9f768
commit
9d25435105
|
@ -50,13 +50,13 @@ module.exports = {
|
||||||
var prop = schemas.BasicTypes.properties[name];
|
var prop = schemas.BasicTypes.properties[name];
|
||||||
var type = typeof prop == 'object' ? prop.type : prop;
|
var type = typeof prop == 'object' ? prop.type : prop;
|
||||||
|
|
||||||
if (type == Realm.Types.FLOAT || type == Realm.Types.DOUBLE) {
|
if (type == 'float' || type == 'double') {
|
||||||
TestCase.assertEqualWithTolerance(object[name], basicTypesValues[name], 0.000001);
|
TestCase.assertEqualWithTolerance(object[name], basicTypesValues[name], 0.000001);
|
||||||
}
|
}
|
||||||
else if (type == Realm.Types.DATA) {
|
else if (type == 'data') {
|
||||||
TestCase.assertArraysEqual(new Uint8Array(object[name]), RANDOM_DATA);
|
TestCase.assertArraysEqual(new Uint8Array(object[name]), RANDOM_DATA);
|
||||||
}
|
}
|
||||||
else if (type == Realm.Types.DATE) {
|
else if (type == 'date') {
|
||||||
TestCase.assertEqual(object[name].getTime(), basicTypesValues[name].getTime());
|
TestCase.assertEqual(object[name].getTime(), basicTypesValues[name].getTime());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -100,13 +100,13 @@ module.exports = {
|
||||||
|
|
||||||
TestCase.assertEqual(nullObject[name], null);
|
TestCase.assertEqual(nullObject[name], null);
|
||||||
|
|
||||||
if (type == Realm.Types.FLOAT || type == Realm.Types.DOUBLE) {
|
if (type == 'float' || type == 'double') {
|
||||||
TestCase.assertEqualWithTolerance(object[name], basicTypesValues[name], 0.000001);
|
TestCase.assertEqualWithTolerance(object[name], basicTypesValues[name], 0.000001);
|
||||||
}
|
}
|
||||||
else if (type == Realm.Types.DATA) {
|
else if (type == 'data') {
|
||||||
TestCase.assertArraysEqual(new Uint8Array(object[name]), RANDOM_DATA);
|
TestCase.assertArraysEqual(new Uint8Array(object[name]), RANDOM_DATA);
|
||||||
}
|
}
|
||||||
else if (type == Realm.Types.DATE) {
|
else if (type == 'date') {
|
||||||
TestCase.assertEqual(object[name].getTime(), basicTypesValues[name].getTime());
|
TestCase.assertEqual(object[name].getTime(), basicTypesValues[name].getTime());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -42,9 +42,9 @@ function convertValue(value, schema, type) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
typeConverters[Realm.Types.DATE] = function(value) { return new Date(value); };
|
typeConverters['date'] = function(value) { return new Date(value); };
|
||||||
typeConverters[Realm.Types.DATA] = function(value) { return new Uint8Array(value); };
|
typeConverters['data'] = function(value) { return new Uint8Array(value); };
|
||||||
typeConverters[Realm.Types.OBJECT] = convertValue;
|
typeConverters['object'] = convertValue;
|
||||||
|
|
||||||
function runQuerySuite(suite) {
|
function runQuerySuite(suite) {
|
||||||
var realm = new Realm({schema: suite.schema});
|
var realm = new Realm({schema: suite.schema});
|
||||||
|
|
|
@ -116,7 +116,7 @@ module.exports = {
|
||||||
}, 'The schema should be an array of ObjectSchema objects');
|
}, 'The schema should be an array of ObjectSchema objects');
|
||||||
|
|
||||||
TestCase.assertThrows(function() {
|
TestCase.assertThrows(function() {
|
||||||
new Realm({schema: [{properties: {intCol: Realm.Types.INT}}]});
|
new Realm({schema: [{properties: {intCol: 'int'}}]});
|
||||||
}, 'The schema should be an array of ObjectSchema objects');
|
}, 'The schema should be an array of ObjectSchema objects');
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ var Realm = require('realm');
|
||||||
exports.TestObject = {
|
exports.TestObject = {
|
||||||
name: 'TestObject',
|
name: 'TestObject',
|
||||||
properties: {
|
properties: {
|
||||||
doubleCol: Realm.Types.DOUBLE,
|
doubleCol: 'double',
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -31,9 +31,9 @@ function PersonObject() {}
|
||||||
PersonObject.schema = {
|
PersonObject.schema = {
|
||||||
name: 'PersonObject',
|
name: 'PersonObject',
|
||||||
properties: {
|
properties: {
|
||||||
name: Realm.Types.STRING,
|
name: 'string',
|
||||||
age: Realm.Types.DOUBLE,
|
age: 'double',
|
||||||
married: {type: Realm.Types.BOOL, default: false},
|
married: {type: 'bool', default: false},
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
PersonObject.prototype.description = function() {
|
PersonObject.prototype.description = function() {
|
||||||
|
@ -54,26 +54,26 @@ exports.PersonList = {
|
||||||
exports.BasicTypes = {
|
exports.BasicTypes = {
|
||||||
name: 'BasicTypesObject',
|
name: 'BasicTypesObject',
|
||||||
properties: {
|
properties: {
|
||||||
boolCol: Realm.Types.BOOL,
|
boolCol: 'bool',
|
||||||
intCol: Realm.Types.INT,
|
intCol: 'int',
|
||||||
floatCol: Realm.Types.FLOAT,
|
floatCol: 'float',
|
||||||
doubleCol: Realm.Types.DOUBLE,
|
doubleCol: 'double',
|
||||||
stringCol: Realm.Types.STRING,
|
stringCol: 'string',
|
||||||
dateCol: Realm.Types.DATE,
|
dateCol: 'date',
|
||||||
dataCol: Realm.Types.DATA,
|
dataCol: 'data',
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.NullableBasicTypes = {
|
exports.NullableBasicTypes = {
|
||||||
name: 'NullableBasicTypesObject',
|
name: 'NullableBasicTypesObject',
|
||||||
properties: {
|
properties: {
|
||||||
boolCol: {type: Realm.Types.BOOL, optional: true},
|
boolCol: {type: 'bool', optional: true},
|
||||||
intCol: {type: Realm.Types.INT, optional: true},
|
intCol: {type: 'int', optional: true},
|
||||||
floatCol: {type: Realm.Types.FLOAT, optional: true},
|
floatCol: {type: 'float', optional: true},
|
||||||
doubleCol: {type: Realm.Types.DOUBLE, optional: true},
|
doubleCol: {type: 'double', optional: true},
|
||||||
stringCol: {type: Realm.Types.STRING, optional: true},
|
stringCol: {type: 'string', optional: true},
|
||||||
dateCol: {type: Realm.Types.DATE, optional: true},
|
dateCol: {type: 'date', optional: true},
|
||||||
dataCol: {type: Realm.Types.DATA, optional: true},
|
dataCol: {type: 'data', optional: true},
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -92,8 +92,8 @@ exports.LinkTypes = {
|
||||||
name: 'LinkTypesObject',
|
name: 'LinkTypesObject',
|
||||||
properties: {
|
properties: {
|
||||||
objectCol: 'TestObject',
|
objectCol: 'TestObject',
|
||||||
objectCol1: {type: Realm.Types.OBJECT, objectType: 'TestObject'},
|
objectCol1: {type: 'object', objectType: 'TestObject'},
|
||||||
arrayCol: {type: Realm.Types.LIST, objectType: 'TestObject'},
|
arrayCol: {type: 'list', objectType: 'TestObject'},
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -101,8 +101,8 @@ exports.IntPrimary = {
|
||||||
name: 'IntPrimaryObject',
|
name: 'IntPrimaryObject',
|
||||||
primaryKey: 'primaryCol',
|
primaryKey: 'primaryCol',
|
||||||
properties: {
|
properties: {
|
||||||
primaryCol: Realm.Types.INT,
|
primaryCol: 'int',
|
||||||
valueCol: Realm.Types.STRING,
|
valueCol: 'string',
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -110,8 +110,8 @@ exports.StringPrimary = {
|
||||||
name: 'StringPrimaryObject',
|
name: 'StringPrimaryObject',
|
||||||
primaryKey: 'primaryCol',
|
primaryKey: 'primaryCol',
|
||||||
properties: {
|
properties: {
|
||||||
primaryCol: Realm.Types.STRING,
|
primaryCol: 'string',
|
||||||
valueCol: Realm.Types.INT,
|
valueCol: 'int',
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -119,64 +119,64 @@ exports.AllTypes = {
|
||||||
name: 'AllTypesObject',
|
name: 'AllTypesObject',
|
||||||
primaryKey: 'primaryCol',
|
primaryKey: 'primaryCol',
|
||||||
properties: {
|
properties: {
|
||||||
primaryCol: Realm.Types.STRING,
|
primaryCol: 'string',
|
||||||
boolCol: Realm.Types.BOOL,
|
boolCol: 'bool',
|
||||||
intCol: Realm.Types.INT,
|
intCol: 'int',
|
||||||
floatCol: Realm.Types.FLOAT,
|
floatCol: 'float',
|
||||||
doubleCol: Realm.Types.DOUBLE,
|
doubleCol: 'double',
|
||||||
stringCol: Realm.Types.STRING,
|
stringCol: 'string',
|
||||||
dateCol: Realm.Types.DATE,
|
dateCol: 'date',
|
||||||
dataCol: Realm.Types.DATA,
|
dataCol: 'data',
|
||||||
objectCol: 'TestObject',
|
objectCol: 'TestObject',
|
||||||
arrayCol: {type: Realm.Types.LIST, objectType: 'TestObject'},
|
arrayCol: {type: 'list', objectType: 'TestObject'},
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.DefaultValues = {
|
exports.DefaultValues = {
|
||||||
name: 'DefaultValuesObject',
|
name: 'DefaultValuesObject',
|
||||||
properties: {
|
properties: {
|
||||||
boolCol: {type: Realm.Types.BOOL, default: true},
|
boolCol: {type: 'bool', default: true},
|
||||||
intCol: {type: Realm.Types.INT, default: -1},
|
intCol: {type: 'int', default: -1},
|
||||||
floatCol: {type: Realm.Types.FLOAT, default: -1.1},
|
floatCol: {type: 'float', default: -1.1},
|
||||||
doubleCol: {type: Realm.Types.DOUBLE, default: -1.11},
|
doubleCol: {type: 'double', default: -1.11},
|
||||||
stringCol: {type: Realm.Types.STRING, default: 'defaultString'},
|
stringCol: {type: 'string', default: 'defaultString'},
|
||||||
dateCol: {type: Realm.Types.DATE, default: new Date(1.111)},
|
dateCol: {type: 'date', default: new Date(1.111)},
|
||||||
dataCol: {type: Realm.Types.DATA, default: new ArrayBuffer(1)},
|
dataCol: {type: 'data', default: new ArrayBuffer(1)},
|
||||||
objectCol: {type: 'TestObject', default: {doubleCol: 1}},
|
objectCol: {type: 'TestObject', default: {doubleCol: 1}},
|
||||||
nullObjectCol: {type: 'TestObject', default: null},
|
nullObjectCol: {type: 'TestObject', default: null},
|
||||||
arrayCol: {type: Realm.Types.LIST, objectType: 'TestObject', default: [{doubleCol: 2}]},
|
arrayCol: {type: 'list', objectType: 'TestObject', default: [{doubleCol: 2}]},
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.QueryObject = {
|
exports.QueryObject = {
|
||||||
name: 'QueryObject',
|
name: 'QueryObject',
|
||||||
properties: [
|
properties: [
|
||||||
{name: 'bool1', type: Realm.Types.BOOL},
|
{name: 'bool1', type: 'bool'},
|
||||||
{name: 'bool2', type: Realm.Types.BOOL},
|
{name: 'bool2', type: 'bool'},
|
||||||
{name: 'int1', type: Realm.Types.INT},
|
{name: 'int1', type: 'int'},
|
||||||
{name: 'int2', type: Realm.Types.INT},
|
{name: 'int2', type: 'int'},
|
||||||
{name: 'float1', type: Realm.Types.FLOAT},
|
{name: 'float1', type: 'float'},
|
||||||
{name: 'float2', type: Realm.Types.FLOAT},
|
{name: 'float2', type: 'float'},
|
||||||
{name: 'double1', type: Realm.Types.DOUBLE},
|
{name: 'double1', type: 'double'},
|
||||||
{name: 'double2', type: Realm.Types.DOUBLE},
|
{name: 'double2', type: 'double'},
|
||||||
{name: 'string1', type: Realm.Types.STRING},
|
{name: 'string1', type: 'string'},
|
||||||
{name: 'string2', type: Realm.Types.STRING},
|
{name: 'string2', type: 'string'},
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.NullQueryObject = {
|
exports.NullQueryObject = {
|
||||||
name: 'NullQueryObject',
|
name: 'NullQueryObject',
|
||||||
properties: [
|
properties: [
|
||||||
{name: 'bool1', type: Realm.Types.BOOL},
|
{name: 'bool1', type: 'bool'},
|
||||||
{name: 'bool2', type: Realm.Types.BOOL},
|
{name: 'bool2', type: 'bool'},
|
||||||
{name: 'int1', type: Realm.Types.INT},
|
{name: 'int1', type: 'int'},
|
||||||
{name: 'int2', type: Realm.Types.INT},
|
{name: 'int2', type: 'int'},
|
||||||
{name: 'float1', type: Realm.Types.FLOAT},
|
{name: 'float1', type: 'float'},
|
||||||
{name: 'float2', type: Realm.Types.FLOAT},
|
{name: 'float2', type: 'float'},
|
||||||
{name: 'double1', type: Realm.Types.DOUBLE},
|
{name: 'double1', type: 'double'},
|
||||||
{name: 'double2', type: Realm.Types.DOUBLE},
|
{name: 'double2', type: 'double'},
|
||||||
{name: 'string1', type: Realm.Types.STRING},
|
{name: 'string1', type: 'string'},
|
||||||
{name: 'string2', type: Realm.Types.STRING},
|
{name: 'string2', type: 'string'},
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue