Skip to content

Commit

Permalink
test(#232): 조상 판별 함수 테스트 작성
Browse files Browse the repository at this point in the history
  • Loading branch information
Conut-1 committed Dec 13, 2023
1 parent 8b47b87 commit 9d1f94e
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions nestjs-BE/server/src/crdt/tree.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { Tree } from './tree';

it('isAncestor', () => {
const tree = new Tree<string>();

tree.addNode('a', 'root', 'test');
tree.addNode('b', 'a', 'test');
tree.addNode('c', 'b', 'test');
tree.addNode('d', 'a', 'test');
tree.addNode('e', 'b', 'test');

expect(tree.isAncestor('c', 'a')).toBeTruthy();
expect(tree.isAncestor('c', 'root')).toBeTruthy();
expect(tree.isAncestor('d', 'root')).toBeTruthy();
expect(tree.isAncestor('d', 'a')).toBeTruthy();
expect(tree.isAncestor('c', 'e')).toBeFalsy();
expect(tree.isAncestor('e', 'c')).toBeFalsy();
expect(tree.isAncestor('c', 'd')).toBeFalsy();
});

0 comments on commit 9d1f94e

Please sign in to comment.