From aeed9772e0306ea22496a62cc3b0df9b1e5942ce Mon Sep 17 00:00:00 2001 From: Conut-1 <1mim1@naver.com> Date: Thu, 14 Dec 2023 00:21:35 +0900 Subject: [PATCH] =?UTF-8?q?test(#232):=20=EC=88=9C=ED=99=98=20=ED=85=8C?= =?UTF-8?q?=EC=8A=A4=ED=8A=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nestjs-BE/server/src/crdt/crdt-tree.spec.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/nestjs-BE/server/src/crdt/crdt-tree.spec.ts b/nestjs-BE/server/src/crdt/crdt-tree.spec.ts index 98c02598..c02253ed 100644 --- a/nestjs-BE/server/src/crdt/crdt-tree.spec.ts +++ b/nestjs-BE/server/src/crdt/crdt-tree.spec.ts @@ -59,3 +59,18 @@ it('crdt tree 역직렬화', () => { expect(JSON.stringify(tree)).toEqual(JSON.stringify(parsedTree)); }); + +it('crdt tree 순환', () => { + const tree = new CrdtTree('1'); + + const op1 = tree.generateOperationAdd('a', 'root', 'hello'); + const op2 = tree.generateOperationAdd('b', 'root', 'hi'); + const op3 = tree.generateOperationAdd('c', 'a', 'good'); + const op4 = tree.generateOperationAdd('d', 'b', 'bad'); + const op5 = tree.generateOperationMove('a', 'b'); + const op6 = tree.generateOperationMove('b', 'a'); + + tree.applyOperations([op1, op2, op3, op4, op5, op6]); + + expect(tree.tree.get('b').parentId).toEqual('root'); +});