Revert user-tests to still use callbacks for login/register etc
This commit is contained in:
parent
115a2c9902
commit
9366de14ef
|
@ -297,17 +297,23 @@ module.exports = {
|
||||||
},
|
},
|
||||||
|
|
||||||
testRetrieveAccount() {
|
testRetrieveAccount() {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
if (!isNodeProcess) {
|
if (!isNodeProcess) {
|
||||||
return Promise.resolve()
|
resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!global.testAdminUserInfo) {
|
if (!global.testAdminUserInfo) {
|
||||||
return Promise.reject("Test requires an admin user");
|
reject("Test requires an admin user");
|
||||||
}
|
}
|
||||||
return Realm.Sync.User.login('http://localhost:9080', global.testAdminUserInfo.username, global.testAdminUserInfo.password)
|
|
||||||
.then(user => {
|
Realm.Sync.User.login('http://localhost:9080', global.testAdminUserInfo.username, global.testAdminUserInfo.password, (error, user) => {
|
||||||
|
if (error) {
|
||||||
|
reject(error);
|
||||||
|
}
|
||||||
|
|
||||||
TestCase.assertTrue(user.isAdmin, "Test requires an admin user");
|
TestCase.assertTrue(user.isAdmin, "Test requires an admin user");
|
||||||
return user.retrieveAccount()
|
|
||||||
})
|
user.retrieveAccount('password', global.testAdminUserInfo.username)
|
||||||
.then(account => {
|
.then(account => {
|
||||||
// {
|
// {
|
||||||
// "provider_id": "admin",
|
// "provider_id": "admin",
|
||||||
|
@ -317,28 +323,38 @@ module.exports = {
|
||||||
// "isAdmin": true,
|
// "isAdmin": true,
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
TestCase.assertEqual(account.provider_id, global.testAdminUserInfo.username);
|
TestCase.assertEqual(account.provider_id, global.testAdminUserInfo.username);
|
||||||
TestCase.assertEqual(account.provider, 'password');
|
TestCase.assertEqual(account.provider, 'password');
|
||||||
TestCase.assertTrue(account.user);
|
TestCase.assertTrue(account.user);
|
||||||
TestCase.assertTrue(account.user.isAdmin !== undefined);
|
TestCase.assertTrue(account.user.isAdmin !== undefined);
|
||||||
TestCase.assertTrue(account.user.id);
|
TestCase.assertTrue(account.user.id);
|
||||||
|
resolve();
|
||||||
})
|
})
|
||||||
.catch(e => reject(e));
|
.catch(e => reject(e));
|
||||||
|
})
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
testRetrieveNotExistingAccount() {
|
testRetrieveNotExistingAccount() {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
if (!isNodeProcess) {
|
if (!isNodeProcess) {
|
||||||
return Promise.resolve()
|
resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!global.testAdminUserInfo) {
|
if (!global.testAdminUserInfo) {
|
||||||
return Promise.reject("Test requires an admin user");
|
reject("Test requires an admin user");
|
||||||
}
|
}
|
||||||
return Realm.Sync.User.login('http://localhost:9080', global.testAdminUserInfo.username, global.testAdminUserInfo.password)
|
|
||||||
.then(user => {
|
Realm.Sync.User.login('http://localhost:9080', global.testAdminUserInfo.username, global.testAdminUserInfo.password, (error, user) => {
|
||||||
|
if (error) {
|
||||||
|
reject(error);
|
||||||
|
}
|
||||||
|
|
||||||
TestCase.assertTrue(user.isAdmin, "Test requires an admin user");
|
TestCase.assertTrue(user.isAdmin, "Test requires an admin user");
|
||||||
|
|
||||||
let notExistingUsername = uuid();
|
let notExistingUsername = uuid();
|
||||||
return user.retrieveAccount('password', notExistingUsername)
|
user.retrieveAccount('password', notExistingUsername)
|
||||||
})
|
|
||||||
.then(account => {
|
.then(account => {
|
||||||
reject("Retrieving not existing account should fail");
|
reject("Retrieving not existing account should fail");
|
||||||
})
|
})
|
||||||
|
@ -346,6 +362,8 @@ module.exports = {
|
||||||
TestCase.assertEqual(e.code, 404);
|
TestCase.assertEqual(e.code, 404);
|
||||||
resolve()
|
resolve()
|
||||||
});
|
});
|
||||||
|
})
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
/* This test fails because of realm-object-store #243 . We should use 2 users.
|
/* This test fails because of realm-object-store #243 . We should use 2 users.
|
||||||
|
|
Loading…
Reference in New Issue