From 0f1d916874e6a4bdc339d0280d9dbf15ae7bf6ee Mon Sep 17 00:00:00 2001 From: blagoev Date: Mon, 18 Sep 2017 14:09:04 +0300 Subject: [PATCH] fix users tests (account tests still fail) --- tests/js/user-tests.js | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/tests/js/user-tests.js b/tests/js/user-tests.js index a0fee2f5..0cd6c703 100644 --- a/tests/js/user-tests.js +++ b/tests/js/user-tests.js @@ -123,13 +123,20 @@ module.exports = { testRegisterExistingUser() { var username = uuid(); - return callbackTest((callback) => Realm.Sync.User.register('http://localhost:9080', username, 'password', callback), (error, user) => { - failOnError(error); - assertIsUser(user); - + return new Promise((resolve, reject) => { Realm.Sync.User.register('http://localhost:9080', username, 'password', (error, user) => { - assertIsAuthError(error, 611, "The provided credentials are invalid or a user already exists."); - TestCase.assertUndefined(user); + failOnError(error); + assertIsUser(user); + + Realm.Sync.User.register('http://localhost:9080', username, 'password', (error, user) => { + try { + assertIsAuthError(error, 613, "The account cannot be registered as it exists already."); + TestCase.assertUndefined(user); + resolve(); + } catch(e) { + reject(e); + } + }); }); }); }, @@ -202,7 +209,7 @@ module.exports = { testLoginNonExistingUser() { return callbackTest((callback) => Realm.Sync.User.login('http://localhost:9080', 'does_not', 'exist', callback), (error, user) => { - assertIsAuthError(error, 611, "The provided credentials are invalid or a user already exists."); + assertIsAuthError(error, 611, "The provided credentials are invalid."); TestCase.assertUndefined(user); }); }, @@ -359,7 +366,12 @@ module.exports = { reject("Retrieving not existing account should fail"); }) .catch(e => { - TestCase.assertEqual(e.code, 404); + try { + TestCase.assertEqual(e.code, 404); + } + catch (e) { + reject(e); + } resolve() }); })