mirror of
https://github.com/status-im/realm-js.git
synced 2025-01-11 06:46:03 +00:00
allow setting nullable properties to undefined
This commit is contained in:
parent
36a5a9710a
commit
196a0a15a4
@ -86,7 +86,7 @@ template<> JSValueRef RJSAccessor::default_value_for_property(JSContextRef ctx,
|
||||
}
|
||||
|
||||
template<> bool RJSAccessor::is_null(JSContextRef ctx, JSValueRef &val) {
|
||||
return JSValueIsNull(ctx, val);
|
||||
return JSValueIsNull(ctx, val) || JSValueIsUndefined(ctx, val);
|
||||
}
|
||||
template<> JSValueRef RJSAccessor::null_value(JSContextRef ctx) {
|
||||
return JSValueMakeNull(ctx);
|
||||
|
@ -146,17 +146,20 @@ module.exports = BaseTest.extend({
|
||||
testNullableBasicTypesPropertySetters: function() {
|
||||
var basicTypesValues = [true, 1, 1.1, 1.11, 'string', new Date(1), 'DATA'];
|
||||
var realm = new Realm({schema: [schemas.NullableBasicTypes]});
|
||||
var obj = null;
|
||||
var obj, obj1;
|
||||
|
||||
realm.write(function() {
|
||||
obj = realm.create('NullableBasicTypesObject', basicTypesValues);
|
||||
obj1 = realm.create('NullableBasicTypesObject', basicTypesValues);
|
||||
for (var prop of schemas.NullableBasicTypes.properties) {
|
||||
obj[prop.name] = null;
|
||||
obj1[prop.name] = undefined;
|
||||
}
|
||||
});
|
||||
|
||||
for (var prop of schemas.NullableBasicTypes.properties) {
|
||||
TestCase.assertEqual(obj[prop.name], null);
|
||||
TestCase.assertEqual(obj1[prop.name], null);
|
||||
}
|
||||
|
||||
realm.write(function() {
|
||||
@ -166,28 +169,6 @@ module.exports = BaseTest.extend({
|
||||
TestCase.assertThrows(function() {
|
||||
obj.intCol = 'dog';
|
||||
});
|
||||
|
||||
TestCase.assertThrows(function() {
|
||||
obj.boolCol = undefined;
|
||||
});
|
||||
TestCase.assertThrows(function() {
|
||||
obj.intCol = undefined;
|
||||
});
|
||||
TestCase.assertThrows(function() {
|
||||
obj.floatCol = undefined;
|
||||
});
|
||||
TestCase.assertThrows(function() {
|
||||
obj.doubleCol = undefined;
|
||||
});
|
||||
TestCase.assertThrows(function() {
|
||||
obj.stringCol = undefined;
|
||||
});
|
||||
TestCase.assertThrows(function() {
|
||||
obj.dateCol = undefined;
|
||||
});
|
||||
TestCase.assertThrows(function() {
|
||||
obj.dataCol = undefined;
|
||||
});
|
||||
});
|
||||
|
||||
TestCase.assertThrows(function() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user