1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-24 10:27:10 +02:00

Minor tweals

This commit is contained in:
Laurent Cozic 2018-03-27 17:48:55 +01:00
parent 2280fb5c43
commit 4f5e7367d0
3 changed files with 15 additions and 11 deletions

View File

@ -542,11 +542,11 @@ describe('Synchronizer', function() {
let n1 = await Note.save({ title: "mynote" });
let n2 = await Note.save({ title: "mynote2" });
let tag = await Tag.save({ title: 'mytag' });
await synchronizer().start();
let context1 = await synchronizer().start();
await switchClient(2);
await synchronizer().start();
let context2 = await synchronizer().start();
if (withEncryption) {
const masterKey_2 = await MasterKey.load(masterKey.id);
await encryptionService().loadMasterKey(masterKey_2, '123456', true);
@ -560,21 +560,21 @@ describe('Synchronizer', function() {
await Tag.addNote(remoteTag.id, n2.id);
let noteIds = await Tag.noteIds(tag.id);
expect(noteIds.length).toBe(2);
await synchronizer().start();
context2 = await synchronizer().start({ context: context2 });
await switchClient(1);
await synchronizer().start();
context1 = await synchronizer().start({ context: context1 });
let remoteNoteIds = await Tag.noteIds(tag.id);
expect(remoteNoteIds.length).toBe(2);
await Tag.removeNote(tag.id, n1.id);
remoteNoteIds = await Tag.noteIds(tag.id);
expect(remoteNoteIds.length).toBe(1);
await synchronizer().start();
context1 = await synchronizer().start({ context: context1 });
await switchClient(2);
await synchronizer().start();
context2 = await synchronizer().start({ context: context2 });
noteIds = await Tag.noteIds(tag.id);
expect(noteIds.length).toBe(1);
expect(remoteNoteIds[0]).toBe(noteIds[0]);

View File

@ -57,9 +57,9 @@ SyncTargetRegistry.addClass(SyncTargetNextcloud);
SyncTargetRegistry.addClass(SyncTargetDropbox);
// const syncTargetId_ = SyncTargetRegistry.nameToId("nextcloud");
// const syncTargetId_ = SyncTargetRegistry.nameToId("memory");
const syncTargetId_ = SyncTargetRegistry.nameToId("memory");
//const syncTargetId_ = SyncTargetRegistry.nameToId('filesystem');
const syncTargetId_ = SyncTargetRegistry.nameToId('dropbox');
// const syncTargetId_ = SyncTargetRegistry.nameToId('dropbox');
const syncDir = __dirname + '/../tests/sync';
const sleepTime = syncTargetId_ == SyncTargetRegistry.nameToId('filesystem') ? 1001 : 100;//400;
@ -256,7 +256,7 @@ function fileApi() {
const api = new DropboxApi();
const authTokenPath = __dirname + '/support/dropbox-auth.txt';
const authToken = fs.readFileSync(authTokenPath, 'utf8');
if (!authTokenPath) throw new Error('Dropbox auth token missing in ' + authTokenPath);
if (!authToken) throw new Error('Dropbox auth token missing in ' + authTokenPath);
api.setAuthToken(authToken);
fileApi_ = new FileApi('', new FileApiDriverDropbox(api));
}
@ -301,9 +301,10 @@ function asyncTest(callback) {
await callback();
} catch (error) {
console.error(error);
}
} finally {
done();
}
}
}
module.exports = { setupDatabase, setupDatabaseAndSynchronizer, db, synchronizer, fileApi, sleep, clearDatabase, switchClient, syncTargetId, objectsEqual, checkThrowAsync, encryptionService, loadEncryptionMasterKey, fileContentEqual, decryptionWorker, asyncTest };

View File

@ -85,6 +85,9 @@ shim.fetchRequestCanBeRetried = function(error) {
// Code: ETIMEDOUT
if (error.code === 'ETIMEDOUT') return true;
// ECONNREFUSED is generally temporary
if (error.code === 'ECONNREFUSED') return true;
return false;
};