From 71ae18c254ec3db2a0f7278c977330bbdf053488 Mon Sep 17 00:00:00 2001 From: Laurent Cozic Date: Sat, 1 Jul 2017 16:17:49 +0100 Subject: [PATCH] Unit test case when two clients both delete folders --- CliClient/tests/synchronizer.js | 40 +++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/CliClient/tests/synchronizer.js b/CliClient/tests/synchronizer.js index 2d5076300..4fa82e41d 100644 --- a/CliClient/tests/synchronizer.js +++ b/CliClient/tests/synchronizer.js @@ -319,6 +319,46 @@ describe('Synchronizer', function() { done(); }); + it('should cross delete all folders', async (done) => { + // If client1 and 2 have two folders, client 1 deletes item 1 and client + // 2 deletes item 2, they should both end up with no items after sync. + + let folder1 = await Folder.save({ title: "folder1" }); + let folder2 = await Folder.save({ title: "folder2" }); + await synchronizer().start(); + + await switchClient(2); + + await synchronizer().start(); + + await sleep(0.1); + + await Folder.delete(folder1.id); + + await switchClient(1); + + await Folder.delete(folder2.id); + + await synchronizer().start(); + + await switchClient(2); + + await synchronizer().start(); + + let items2 = await allItems(); + + await switchClient(1); + + await synchronizer().start(); + + let items1 = await allItems(); + + expect(items1.length).toBe(0); + expect(items1.length).toBe(items2.length); + + done(); + }); + it('should handle conflict when remote note is deleted then local note is modified', async (done) => { let folder1 = await Folder.save({ title: "folder1" }); let note1 = await Note.save({ title: "un", parent_id: folder1.id });