mirror of
https://github.com/status-im/realm-js.git
synced 2025-02-17 09:06:26 +00:00
Add more tests and fix add_notification
This commit is contained in:
parent
bf85c285a0
commit
1d4bb7c2ad
@ -638,6 +638,9 @@ void RealmClass<T>::add_listener(ContextType ctx, ObjectType this_object, size_t
|
|||||||
auto callback = Value::validated_to_function(ctx, arguments[1]);
|
auto callback = Value::validated_to_function(ctx, arguments[1]);
|
||||||
|
|
||||||
SharedRealm realm = *get_internal<T, RealmClass<T>>(this_object);
|
SharedRealm realm = *get_internal<T, RealmClass<T>>(this_object);
|
||||||
|
if (realm->is_closed()) {
|
||||||
|
throw ClosedRealmException();
|
||||||
|
}
|
||||||
get_delegate<T>(realm.get())->add_notification(callback);
|
get_delegate<T>(realm.get())->add_notification(callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -657,6 +657,8 @@ module.exports = {
|
|||||||
|
|
||||||
var person = realm.objects('PersonObject')[0];
|
var person = realm.objects('PersonObject')[0];
|
||||||
|
|
||||||
|
// The tests below assert that everthing throws when
|
||||||
|
// operating on a closed realm
|
||||||
realm.close();
|
realm.close();
|
||||||
|
|
||||||
TestCase.assertThrows(function() {
|
TestCase.assertThrows(function() {
|
||||||
@ -666,6 +668,28 @@ module.exports = {
|
|||||||
TestCase.assertThrows(function() {
|
TestCase.assertThrows(function() {
|
||||||
realm.objects('PersonObject');
|
realm.objects('PersonObject');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
TestCase.assertThrows(function() {
|
||||||
|
realm.addListener('change', () => {});
|
||||||
|
});
|
||||||
|
|
||||||
|
TestCase.assertThrows(function() {
|
||||||
|
realm.create('PersonObject', {name: 'Ari', age: 10});
|
||||||
|
});
|
||||||
|
|
||||||
|
TestCase.assertThrows(function() {
|
||||||
|
realm.delete(person);
|
||||||
|
});
|
||||||
|
|
||||||
|
TestCase.assertThrows(function() {
|
||||||
|
realm.deleteAll();
|
||||||
|
});
|
||||||
|
|
||||||
|
TestCase.assertThrows(function() {
|
||||||
|
realm.write(() => {});
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
testRealmObjectForPrimaryKey: function() {
|
testRealmObjectForPrimaryKey: function() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user