Skip to content

Commit

Permalink
possible fix to session tests timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
blagoev committed Apr 20, 2017
1 parent 7543c12 commit c959cc7
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions tests/js/session-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 54,14 @@ module.exports = {
const accessTokenRefreshed = this;

function postTokenRefreshChecks(sender, error) {
TestCase.assertEqual(error, accessTokenRefreshed);
TestCase.assertEqual(sender.url, `realm://localhost:9080/${user.identity}/myrealm`);
resolve();
try {
TestCase.assertEqual(error, accessTokenRefreshed);
TestCase.assertEqual(sender.url, `realm://localhost:9080/${user.identity}/myrealm`);
resolve();
}
catch (e) {
_reject(e)
}
};

// Let the error handler trigger our checks when the access token was refreshed.
Expand All @@ -66,24 71,30 @@ module.exports = {
const realm = new Realm(config);
const session = realm.syncSession;


TestCase.assertInstanceOf(session, Realm.Sync.Session);
TestCase.assertEqual(session.user.identity, user.identity);
TestCase.assertEqual(session.config.url, config.sync.url);
TestCase.assertEqual(session.config.user.identity, config.sync.user.identity);
TestCase.assertUndefined(session.url);
TestCase.assertEqual(session.state, 'active');
});
});
})
},

testErrorHandling() {
return promisifiedRegister('http://localhost:9080', uuid(), 'password').then(user => {
return new Promise((resolve) => {
return new Promise((resolve, _reject) => {
const config = { sync: { user, url: 'realm://localhost:9080/~/myrealm' } };
config.sync.error = (sender, error) => {
TestCase.assertEqual(error.message, 'simulated error');
TestCase.assertEqual(error.code, 123);
resolve();
try {
TestCase.assertEqual(error.message, 'simulated error');
TestCase.assertEqual(error.code, 123);
resolve();
}
catch (e) {
_reject(e);
}
};
const realm = new Realm(config);
const session = realm.syncSession;
Expand Down

0 comments on commit c959cc7

Please sign in to comment.