mirror of
https://github.com/status-im/realm-js.git
synced 2025-02-17 00:56:22 +00:00
adding promisified apis
This commit is contained in:
parent
eac393571d
commit
78515e3b48
@ -37,7 +37,7 @@ X.Y.Z Release notes
|
|||||||
* Added various methods for permission management (#1204).
|
* Added various methods for permission management (#1204).
|
||||||
|
|
||||||
### Bug fixes
|
### Bug fixes
|
||||||
* None
|
* Removed `loginWithProvider` from TypeScript definition files. This API never existed and was incorrectly added.
|
||||||
|
|
||||||
|
|
||||||
1.10.3 Release notes (2017-8-16)
|
1.10.3 Release notes (2017-8-16)
|
||||||
|
@ -135,9 +135,10 @@ class User {
|
|||||||
* @param {string} server - authentication server
|
* @param {string} server - authentication server
|
||||||
* @param {string} username
|
* @param {string} username
|
||||||
* @param {string} password
|
* @param {string} password
|
||||||
* @param {function(error, user)} callback - called with the following arguments:
|
* @param {function(error, user)} [callback] - called with the following arguments:
|
||||||
* - `error` - an Error object is provided on failure
|
* - `error` - an Error object is provided on failure
|
||||||
* - `user` - a valid User object on success
|
* - `user` - a valid User object on success
|
||||||
|
* @returns {Promise<User>} Returns a promise with a user only if the callback was not specified
|
||||||
*/
|
*/
|
||||||
static login(server, username, password, callback) {}
|
static login(server, username, password, callback) {}
|
||||||
|
|
||||||
@ -148,9 +149,10 @@ class User {
|
|||||||
* @param {string} options.provider - The provider type
|
* @param {string} options.provider - The provider type
|
||||||
* @param {string} options.providerToken - The access token for the given provider
|
* @param {string} options.providerToken - The access token for the given provider
|
||||||
* @param {object} [options.userInfo] - A map containing additional data required by the provider
|
* @param {object} [options.userInfo] - A map containing additional data required by the provider
|
||||||
* @param {function(error, User)} callback - called with the following arguments:
|
* @param {function(error, User)} [callback] - an optional called with the following arguments:
|
||||||
* - `error` - an Error object is provided on failure
|
* - `error` - an Error object is provided on failure
|
||||||
* - `user` - a valid User object on success
|
* - `user` - a valid User object on success
|
||||||
|
* @return {Promise<User>} Returns a promise with a user only if the callback was not specified
|
||||||
*/
|
*/
|
||||||
static registerWithProvider(server, options, callback) {}
|
static registerWithProvider(server, options, callback) {}
|
||||||
|
|
||||||
@ -159,9 +161,10 @@ class User {
|
|||||||
* @param {string} server - authentication server
|
* @param {string} server - authentication server
|
||||||
* @param {string} username
|
* @param {string} username
|
||||||
* @param {string} password
|
* @param {string} password
|
||||||
* @param {function(error, user)} callback - called with the following arguments:
|
* @param {function(error, user)} [callback] - called with the following arguments:
|
||||||
* - `error` - an Error object is provided on failure
|
* - `error` - an Error object is provided on failure
|
||||||
* - `user` - a valid User object on success
|
* - `user` - a valid User object on success
|
||||||
|
* @return {Promise<User>} Returns a promise with a user only if the callback was not specified
|
||||||
*/
|
*/
|
||||||
static register(server, username, password, callback) {}
|
static register(server, username, password, callback) {}
|
||||||
|
|
||||||
|
@ -77,7 +77,9 @@ module.exports = function(realmConstructor) {
|
|||||||
},
|
},
|
||||||
|
|
||||||
openAsync(config, progressCallback, callback) {
|
openAsync(config, progressCallback, callback) {
|
||||||
|
const message = "Realm.openAsync is now deprecated in favor of Realm.open. This function will be removed in future versions.";
|
||||||
|
(console.warn || console.log).call(console, message);
|
||||||
|
|
||||||
if (!callback) {
|
if (!callback) {
|
||||||
callback = progressCallback;
|
callback = progressCallback;
|
||||||
progressCallback = null;
|
progressCallback = null;
|
||||||
@ -99,7 +101,7 @@ module.exports = function(realmConstructor) {
|
|||||||
//FIXME: RN hangs here. Remove when node's makeCallback alternative is implemented
|
//FIXME: RN hangs here. Remove when node's makeCallback alternative is implemented
|
||||||
setTimeout(() => { callback(null, syncedRealm); }, 1);
|
setTimeout(() => { callback(null, syncedRealm); }, 1);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
callback(e);
|
setTimeout(() => { callback(e); }, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
5
lib/index.d.ts
vendored
5
lib/index.d.ts
vendored
@ -264,9 +264,11 @@ declare namespace Realm.Sync {
|
|||||||
readonly server: string;
|
readonly server: string;
|
||||||
readonly token: string;
|
readonly token: string;
|
||||||
static adminUser(adminToken: string, server?: string): User;
|
static adminUser(adminToken: string, server?: string): User;
|
||||||
|
static login(server: string, username: string, password: string): Promise<Realm.Sync.User>;
|
||||||
static login(server: string, username: string, password: string, callback: (error: any, user: User) => void): void;
|
static login(server: string, username: string, password: string, callback: (error: any, user: User) => void): void;
|
||||||
static loginWithProvider(server: string, provider: string, providerToken: string, callback: (error: any, user: User) => void): void;
|
static register(server: string, username: string, password: string): Promise<Realm.Sync.User>;
|
||||||
static register(server: string, username: string, password: string, callback: (error: any, user: User) => void): void;
|
static register(server: string, username: string, password: string, callback: (error: any, user: User) => void): void;
|
||||||
|
static registerWithProvider(server: string, options: { provider: string, providerToken: string, userInfo: any }): Promise<Realm.Sync.User>;
|
||||||
static registerWithProvider(server: string, options: { provider: string, providerToken: string, userInfo: any }, callback: (error: Error | null, user: User | null) => void): void;
|
static registerWithProvider(server: string, options: { provider: string, providerToken: string, userInfo: any }, callback: (error: Error | null, user: User | null) => void): void;
|
||||||
logout(): void;
|
logout(): void;
|
||||||
openManagementRealm(): Realm;
|
openManagementRealm(): Realm;
|
||||||
@ -446,6 +448,7 @@ declare class Realm {
|
|||||||
*/
|
*/
|
||||||
static open(config: Realm.Configuration): ProgressPromise;
|
static open(config: Realm.Configuration): ProgressPromise;
|
||||||
/**
|
/**
|
||||||
|
* @deprecated in favor of `Realm.open`
|
||||||
* Open a realm asynchronously with a callback. If the realm is synced, it will be fully synchronized before it is available.
|
* Open a realm asynchronously with a callback. If the realm is synced, it will be fully synchronized before it is available.
|
||||||
* @param {Configuration} config
|
* @param {Configuration} config
|
||||||
* @param {ProgressNotificationCallback} progressCallback? a progress notification callback for 'download' direction and 'forCurrentlyOutstandingWork' mode
|
* @param {ProgressNotificationCallback} progressCallback? a progress notification callback for 'download' direction and 'forCurrentlyOutstandingWork' mode
|
||||||
|
@ -114,6 +114,15 @@ function refreshAccessToken(user, localRealmPath, realmUrl) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The base authentication method. It fires a JSON POST to the server parameter plus the auth url
|
||||||
|
* For example, if the server parameter is `http://myapp.com`, this url will post to `http://myapp.com/auth`
|
||||||
|
* @param {object} userConstructor
|
||||||
|
* @param {string} server the http or https server url
|
||||||
|
* @param {object} json the json to post to the auth endpoint
|
||||||
|
* @param {Function} callback an optional callback with an error and user parameter
|
||||||
|
* @returns {Promise} only returns a promise if the callback parameter was omitted
|
||||||
|
*/
|
||||||
function _authenticate(userConstructor, server, json, callback) {
|
function _authenticate(userConstructor, server, json, callback) {
|
||||||
json.app_id = '';
|
json.app_id = '';
|
||||||
const url = auth_url(server);
|
const url = auth_url(server);
|
||||||
@ -123,7 +132,7 @@ function _authenticate(userConstructor, server, json, callback) {
|
|||||||
headers: postHeaders,
|
headers: postHeaders,
|
||||||
open_timeout: 5000
|
open_timeout: 5000
|
||||||
};
|
};
|
||||||
performFetch(url, options)
|
const promise = performFetch(url, options)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
if (response.status !== 200) {
|
if (response.status !== 200) {
|
||||||
return response.json().then((body) => callback(new AuthError(body)));
|
return response.json().then((body) => callback(new AuthError(body)));
|
||||||
@ -136,8 +145,18 @@ function _authenticate(userConstructor, server, json, callback) {
|
|||||||
callback(undefined, userConstructor.createUser(server, identity, token, false, isAdmin));
|
callback(undefined, userConstructor.createUser(server, identity, token, false, isAdmin));
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (callback) {
|
||||||
|
promise.then(user => {
|
||||||
|
callback(null, user);
|
||||||
})
|
})
|
||||||
.catch(callback);
|
.catch(err => {
|
||||||
|
callback(err)
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
return promise;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const staticMethods = {
|
const staticMethods = {
|
||||||
@ -164,20 +183,30 @@ const staticMethods = {
|
|||||||
|
|
||||||
register(server, username, password, callback) {
|
register(server, username, password, callback) {
|
||||||
checkTypes(arguments, ['string', 'string', 'string', 'function']);
|
checkTypes(arguments, ['string', 'string', 'string', 'function']);
|
||||||
_authenticate(this, server, {
|
const json = {
|
||||||
provider: 'password',
|
provider: 'password',
|
||||||
user_info: { password: password, register: true },
|
user_info: { password: password, register: true },
|
||||||
data: username
|
data: username
|
||||||
}, callback);
|
};
|
||||||
|
if (callback) {
|
||||||
|
_authenticate(this, server, json, callback);
|
||||||
|
} else {
|
||||||
|
return _authenticate(this, server)
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
login(server, username, password, callback) {
|
login(server, username, password, callback) {
|
||||||
checkTypes(arguments, ['string', 'string', 'string', 'function']);
|
checkTypes(arguments, ['string', 'string', 'string', 'function']);
|
||||||
_authenticate(this, server, {
|
const json = {
|
||||||
provider: 'password',
|
provider: 'password',
|
||||||
user_info: { password: password },
|
user_info: { password: password },
|
||||||
data: username
|
data: username
|
||||||
}, callback);
|
};
|
||||||
|
if (callback) {
|
||||||
|
_authenticate(this, server, json, callback);
|
||||||
|
} else {
|
||||||
|
return _authenticate(this, server)
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
registerWithProvider(server, options, callback) {
|
registerWithProvider(server, options, callback) {
|
||||||
@ -195,16 +224,20 @@ const staticMethods = {
|
|||||||
checkTypes(arguments, ['string', 'object', 'function']);
|
checkTypes(arguments, ['string', 'object', 'function']);
|
||||||
}
|
}
|
||||||
|
|
||||||
let reqOptions = {
|
let json = {
|
||||||
provider: options.provider,
|
provider: options.provider,
|
||||||
data: options.providerToken,
|
data: options.providerToken,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (options.userInfo) {
|
if (options.userInfo) {
|
||||||
reqOptions.user_info = options.userInfo;
|
json.user_info = options.userInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
_authenticate(this, server, reqOptions, callback);
|
if (callback) {
|
||||||
|
_authenticate(this, server, json, callback);
|
||||||
|
} else {
|
||||||
|
return _authenticate(this, server)
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
_refreshAccessToken: refreshAccessToken
|
_refreshAccessToken: refreshAccessToken
|
||||||
@ -233,13 +266,11 @@ const instanceMethods = {
|
|||||||
},
|
},
|
||||||
retrieveAccount(provider, provider_id) {
|
retrieveAccount(provider, provider_id) {
|
||||||
checkTypes(arguments, ['string', 'string']);
|
checkTypes(arguments, ['string', 'string']);
|
||||||
|
|
||||||
const url = url_parse(this.server);
|
const url = url_parse(this.server);
|
||||||
url.set('pathname', `/api/providers/${provider}/accounts/${provider_id}`);
|
url.set('pathname', `/api/providers/${provider}/accounts/${provider_id}`);
|
||||||
const headers = {
|
const headers = {
|
||||||
Authorization: this.token
|
Authorization: this.token
|
||||||
};
|
};
|
||||||
|
|
||||||
const options = {
|
const options = {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
headers,
|
headers,
|
||||||
|
@ -50,32 +50,6 @@ function uuid() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function promisifiedRegister(server, username, password) {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
Realm.Sync.User.register(server, username, password, (error, user) => {
|
|
||||||
if (error) {
|
|
||||||
console.log(`promisifiedRegister ${error}`);
|
|
||||||
reject(error);
|
|
||||||
} else {
|
|
||||||
resolve(user);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function promisifiedLogin(server, username, password) {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
Realm.Sync.User.login(server, username, password, (error, user) => {
|
|
||||||
if (error) {
|
|
||||||
console.log(`promisifiedLogin ${error}`);
|
|
||||||
reject(error);
|
|
||||||
} else {
|
|
||||||
resolve(user);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function runOutOfProcess(nodeJsFilePath) {
|
function runOutOfProcess(nodeJsFilePath) {
|
||||||
var nodeArgs = Array.prototype.slice.call(arguments);
|
var nodeArgs = Array.prototype.slice.call(arguments);
|
||||||
let tmpDir = tmp.dirSync();
|
let tmpDir = tmp.dirSync();
|
||||||
@ -111,7 +85,7 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
testProperties() {
|
testProperties() {
|
||||||
return promisifiedRegister('http://localhost:9080', uuid(), 'password').then(user => {
|
return Realm.Sync.User.login('http://localhost:9080', uuid(), 'password').then(user => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
|
|
||||||
const accessTokenRefreshed = this;
|
const accessTokenRefreshed = this;
|
||||||
@ -162,7 +136,7 @@ module.exports = {
|
|||||||
|
|
||||||
return runOutOfProcess(__dirname + '/download-api-helper.js', username, realmName, REALM_MODULE_PATH)
|
return runOutOfProcess(__dirname + '/download-api-helper.js', username, realmName, REALM_MODULE_PATH)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
return promisifiedLogin('http://localhost:9080', username, 'password').then(user => {
|
return Realm.Sync.User.login('http://localhost:9080', username, 'password').then(user => {
|
||||||
const accessTokenRefreshed = this;
|
const accessTokenRefreshed = this;
|
||||||
let successCounter = 0;
|
let successCounter = 0;
|
||||||
|
|
||||||
@ -198,7 +172,7 @@ module.exports = {
|
|||||||
|
|
||||||
return runOutOfProcess(__dirname + '/download-api-helper.js', username, realmName, REALM_MODULE_PATH)
|
return runOutOfProcess(__dirname + '/download-api-helper.js', username, realmName, REALM_MODULE_PATH)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
return promisifiedLogin('http://localhost:9080', username, 'password').then(user => {
|
return Realm.Sync.User.login('http://localhost:9080', username, 'password').then(user => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const accessTokenRefreshed = this;
|
const accessTokenRefreshed = this;
|
||||||
let successCounter = 0;
|
let successCounter = 0;
|
||||||
@ -251,7 +225,7 @@ module.exports = {
|
|||||||
|
|
||||||
return runOutOfProcess(__dirname + '/download-api-helper.js', username, realmName, REALM_MODULE_PATH)
|
return runOutOfProcess(__dirname + '/download-api-helper.js', username, realmName, REALM_MODULE_PATH)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
return promisifiedLogin('http://localhost:9080', username, 'password').then(user => {
|
return Realm.Sync.User.login('http://localhost:9080', username, 'password').then(user => {
|
||||||
const accessTokenRefreshed = this;
|
const accessTokenRefreshed = this;
|
||||||
let successCounter = 0;
|
let successCounter = 0;
|
||||||
let progressNotificationCalled = false;
|
let progressNotificationCalled = false;
|
||||||
@ -287,7 +261,7 @@ module.exports = {
|
|||||||
|
|
||||||
return runOutOfProcess(__dirname + '/download-api-helper.js', username, realmName, REALM_MODULE_PATH)
|
return runOutOfProcess(__dirname + '/download-api-helper.js', username, realmName, REALM_MODULE_PATH)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
return promisifiedLogin('http://localhost:9080', username, 'password').then(user => {
|
return Realm.Sync.User.login('http://localhost:9080', username, 'password').then(user => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
let progressNotificationCalled = false;
|
let progressNotificationCalled = false;
|
||||||
let config = {
|
let config = {
|
||||||
@ -334,7 +308,7 @@ module.exports = {
|
|||||||
|
|
||||||
return runOutOfProcess(__dirname + '/download-api-helper.js', username, realmName, REALM_MODULE_PATH)
|
return runOutOfProcess(__dirname + '/download-api-helper.js', username, realmName, REALM_MODULE_PATH)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
return promisifiedLogin('http://localhost:9080', username, 'password').then(user => {
|
return Realm.Sync.User.login('http://localhost:9080', username, 'password').then(user => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const accessTokenRefreshed = this;
|
const accessTokenRefreshed = this;
|
||||||
let successCounter = 0;
|
let successCounter = 0;
|
||||||
@ -439,7 +413,7 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
testErrorHandling() {
|
testErrorHandling() {
|
||||||
return promisifiedRegister('http://localhost:9080', uuid(), 'password').then(user => {
|
return Realm.Sync.User.register('http://localhost:9080', uuid(), 'password').then(user => {
|
||||||
return new Promise((resolve, _reject) => {
|
return new Promise((resolve, _reject) => {
|
||||||
const config = { sync: { user, url: 'realm://localhost:9080/~/myrealm' } };
|
const config = { sync: { user, url: 'realm://localhost:9080/~/myrealm' } };
|
||||||
config.sync.error = (sender, error) => {
|
config.sync.error = (sender, error) => {
|
||||||
|
@ -297,73 +297,55 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
testRetrieveAccount() {
|
testRetrieveAccount() {
|
||||||
return new Promise((resolve, reject) => {
|
if (!isNodeProcess) {
|
||||||
if (!isNodeProcess) {
|
return Promise.resolve()
|
||||||
resolve();
|
}
|
||||||
}
|
if (!global.testAdminUserInfo) {
|
||||||
|
return Promise.reject("Test requires an admin user");
|
||||||
if (!global.testAdminUserInfo) {
|
}
|
||||||
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 => {
|
|
||||||
// {
|
|
||||||
// "provider_id": "admin",
|
|
||||||
// "provider": "password",
|
|
||||||
// "user": {
|
|
||||||
// "id": "07ac9a0a-a97a-4ee1-b53c-b05a6542035a",
|
|
||||||
// "isAdmin": true,
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
TestCase.assertEqual(account.provider_id, global.testAdminUserInfo.username);
|
|
||||||
TestCase.assertEqual(account.provider, 'password');
|
|
||||||
TestCase.assertTrue(account.user);
|
|
||||||
TestCase.assertTrue(account.user.isAdmin !== undefined);
|
|
||||||
TestCase.assertTrue(account.user.id);
|
|
||||||
resolve();
|
|
||||||
})
|
|
||||||
.catch(e => reject(e));
|
|
||||||
})
|
})
|
||||||
});
|
.then(account => {
|
||||||
|
// {
|
||||||
|
// "provider_id": "admin",
|
||||||
|
// "provider": "password",
|
||||||
|
// "user": {
|
||||||
|
// "id": "07ac9a0a-a97a-4ee1-b53c-b05a6542035a",
|
||||||
|
// "isAdmin": true,
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
TestCase.assertEqual(account.provider_id, global.testAdminUserInfo.username);
|
||||||
|
TestCase.assertEqual(account.provider, 'password');
|
||||||
|
TestCase.assertTrue(account.user);
|
||||||
|
TestCase.assertTrue(account.user.isAdmin !== undefined);
|
||||||
|
TestCase.assertTrue(account.user.id);
|
||||||
|
})
|
||||||
|
.catch(e => reject(e));
|
||||||
},
|
},
|
||||||
|
|
||||||
testRetrieveNotExistingAccount() {
|
testRetrieveNotExistingAccount() {
|
||||||
return new Promise((resolve, reject) => {
|
if (!isNodeProcess) {
|
||||||
if (!isNodeProcess) {
|
return Promise.resolve()
|
||||||
resolve();
|
}
|
||||||
}
|
if (!global.testAdminUserInfo) {
|
||||||
|
return Promise.reject("Test requires an admin user");
|
||||||
if (!global.testAdminUserInfo) {
|
}
|
||||||
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();
|
||||||
user.retrieveAccount('password', notExistingUsername)
|
return user.retrieveAccount('password', notExistingUsername)
|
||||||
.then(account => {
|
|
||||||
reject("Retrieving not existing account should fail");
|
|
||||||
})
|
|
||||||
.catch(e => {
|
|
||||||
TestCase.assertEqual(e.code, 404);
|
|
||||||
resolve()
|
|
||||||
});
|
|
||||||
})
|
})
|
||||||
});
|
.then(account => {
|
||||||
|
reject("Retrieving not existing account should fail");
|
||||||
|
})
|
||||||
|
.catch(e => {
|
||||||
|
TestCase.assertEqual(e.code, 404);
|
||||||
|
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…
x
Reference in New Issue
Block a user