Merge pull request #961 from realm/fix-tests

fix tests not completing on failure
This commit is contained in:
blagoev 2017-04-06 22:56:05 +03:00 committed by GitHub
commit 2ca08161f8
2 changed files with 20 additions and 23 deletions

View File

@ -80,7 +80,7 @@ exports.runTest = function(suiteName, testName) {
if (testMethod) {
// Start fresh in case of a crash in a previous run.
Realm.clearTestState();
console.log("Starting test " + testName);
var promise;
try {
promise = testMethod.call(testSuite);

View File

@ -162,10 +162,9 @@ module.exports = {
},
testLogin() {
return new Promise((resolve, _reject) => {
var username = uuid();
// Create user, logout the new user, then login
callbackTest((callback) => Realm.Sync.User.register('http://localhost:9080', username, 'password', callback), (error, user) => {
return callbackTest((callback) => Realm.Sync.User.register('http://localhost:9080', username, 'password', callback), (error, user) => {
failOnError(error);
user.logout();
@ -177,8 +176,6 @@ module.exports = {
var realm = new Realm({ sync: { user: user, url: 'realm://localhost:9080/~/test' } });
TestCase.assertInstanceOf(realm, Realm);
realm.close();
resolve();
});
});
});
},
@ -226,7 +223,7 @@ module.exports = {
},
testAll() {
return new Promise((resolve, _reject) => {
return new Promise((resolve, reject) => {
let all;
all = Realm.Sync.User.all;
TestCase.assertArrayLength(Object.keys(all), 0);
@ -255,15 +252,14 @@ module.exports = {
user1.logout();
all = Realm.Sync.User.all;
TestCase.assertArrayLength(Object.keys(all), 0);
resolve();
});
});
}).catch(e => reject(e));
});
},
testCurrent() {
return new Promise((resolve, _reject) => {
return new Promise((resolve, reject) => {
TestCase.assertUndefined(Realm.Sync.User.current);
callbackTest((callback) => Realm.Sync.User.register('http://localhost:9080', uuid(), 'password', callback), (error, user1) => {
@ -281,8 +277,9 @@ module.exports = {
TestCase.assertUndefined(Realm.Sync.User.current);
resolve();
});
});
}).catch(e => reject(e));
});
},