Fixing unit tests (discovered on Android). (#1523)
* Fixing unit tests (discovered on Android).
This commit is contained in:
parent
9e18feb898
commit
28f9e027b5
|
@ -10,6 +10,7 @@
|
|||
* Fixed a bug in 3rd party JSON parser: `localeconv()` does not exist on Android API < 21 and should not be called.
|
||||
|
||||
### Internal
|
||||
* Fixed issues in unit tests (`addListener` hangs on Android).
|
||||
* Upgraded to Realm Sync 2.1.8 (no external effects).
|
||||
|
||||
2.0.11 Release notes (2017-11-23)
|
||||
|
|
|
@ -41,7 +41,6 @@ module.exports = {
|
|||
|
||||
TestCase.assertThrowsContaining(() => new Realm.List(), 'constructor');
|
||||
|
||||
TestCase.assertType(Realm.List, 'function');
|
||||
TestCase.assertInstanceOf(Realm.List, Function);
|
||||
},
|
||||
|
||||
|
|
|
@ -423,7 +423,7 @@ module.exports = {
|
|||
testAddListener: function() {
|
||||
if (typeof navigator !== 'undefined' && /Chrome/.test(navigator.userAgent)) { // eslint-disable-line no-undef
|
||||
// FIXME: async callbacks do not work correctly in Chrome debugging mode
|
||||
return;
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
const realm = new Realm({ schema: [schemas.TestObject] });
|
||||
|
@ -433,29 +433,28 @@ module.exports = {
|
|||
realm.create('TestObject', { doubleCol: 3 });
|
||||
});
|
||||
|
||||
let resolve, first = true;
|
||||
let resolve = () => {};
|
||||
let first = true;
|
||||
|
||||
realm.objects('TestObject').addListener((testObjects, changes) => {
|
||||
if (first) {
|
||||
TestCase.assertEqual(testObjects.length, 3);
|
||||
TestCase.assertEqual(changes.insertions.length, 0);
|
||||
}
|
||||
else {
|
||||
TestCase.assertEqual(testObjects.length, 4);
|
||||
TestCase.assertEqual(changes.insertions.length, 1);
|
||||
}
|
||||
first = false;
|
||||
resolve();
|
||||
});
|
||||
|
||||
return new Promise((r, _reject) => {
|
||||
resolve = r;
|
||||
realm.objects('TestObject').addListener((testObjects, changes) => {
|
||||
if (first) {
|
||||
TestCase.assertEqual(testObjects.length, 3);
|
||||
TestCase.assertEqual(changes.insertions.length, 0);
|
||||
}
|
||||
else {
|
||||
TestCase.assertEqual(testObjects.length, 4);
|
||||
TestCase.assertEqual(changes.insertions.length, 1);
|
||||
}
|
||||
first = false;
|
||||
resolve();
|
||||
realm.write(() => {
|
||||
realm.create('TestObject', { doubleCol: 1 });
|
||||
});
|
||||
}).then(() => {
|
||||
return new Promise((r, _reject) => {
|
||||
realm.write(() => {
|
||||
realm.create('TestObject', { doubleCol: 1 });
|
||||
});
|
||||
resolve = r;
|
||||
});
|
||||
})
|
||||
});
|
||||
},
|
||||
|
||||
testResultsAggregateFunctions: function() {
|
||||
|
|
Loading…
Reference in New Issue