fix users tests (account tests still fail)

This commit is contained in:
blagoev 2017-09-18 14:09:04 +03:00
parent b7fef1b6e9
commit 0f1d916874

View File

@ -123,13 +123,20 @@ module.exports = {
testRegisterExistingUser() { testRegisterExistingUser() {
var username = uuid(); var username = uuid();
return callbackTest((callback) => Realm.Sync.User.register('http://localhost:9080', username, 'password', callback), (error, user) => { return new Promise((resolve, reject) => {
Realm.Sync.User.register('http://localhost:9080', username, 'password', (error, user) => {
failOnError(error); failOnError(error);
assertIsUser(user); assertIsUser(user);
Realm.Sync.User.register('http://localhost:9080', username, 'password', (error, user) => { Realm.Sync.User.register('http://localhost:9080', username, 'password', (error, user) => {
assertIsAuthError(error, 611, "The provided credentials are invalid or a user already exists."); try {
assertIsAuthError(error, 613, "The account cannot be registered as it exists already.");
TestCase.assertUndefined(user); TestCase.assertUndefined(user);
resolve();
} catch(e) {
reject(e);
}
});
}); });
}); });
}, },
@ -202,7 +209,7 @@ module.exports = {
testLoginNonExistingUser() { testLoginNonExistingUser() {
return callbackTest((callback) => Realm.Sync.User.login('http://localhost:9080', 'does_not', 'exist', callback), (error, user) => { 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); TestCase.assertUndefined(user);
}); });
}, },
@ -359,7 +366,12 @@ module.exports = {
reject("Retrieving not existing account should fail"); reject("Retrieving not existing account should fail");
}) })
.catch(e => { .catch(e => {
try {
TestCase.assertEqual(e.code, 404); TestCase.assertEqual(e.code, 404);
}
catch (e) {
reject(e);
}
resolve() resolve()
}); });
}) })