File tree Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -551,4 +551,41 @@ def roots_name_and_order
551
551
expect ( tree [ @b ] ) . to eq ( { } )
552
552
end
553
553
end
554
+
555
+ context 'relationship between nodes' do
556
+ before do
557
+ create_label_tree
558
+ end
559
+
560
+ it "checks parent of node" do
561
+ expect ( @a1 . parent_of? ( @b1 ) ) . to be_truthy
562
+ expect ( @c2 . parent_of? ( @d2 ) ) . to be_truthy
563
+ expect ( @c1 . parent_of? ( @b1 ) ) . to be_falsey
564
+ end
565
+
566
+ it "checks children of node" do
567
+ expect ( @d1 . child_of? ( @c1 ) ) . to be_truthy
568
+ expect ( @c2 . child_of? ( @b1 ) ) . to be_truthy
569
+ expect ( @c3 . child_of? ( @b1 ) ) . to be_falsey
570
+ end
571
+
572
+ it "checks root of node" do
573
+ expect ( @a1 . root_of? ( @d1 ) ) . to be_truthy
574
+ expect ( @a1 . root_of? ( @c2 ) ) . to be_truthy
575
+ expect ( @a2 . root_of? ( @c2 ) ) . to be_falsey
576
+ end
577
+
578
+ it "checks ancestor of node" do
579
+ expect ( @a1 . ancestor_of? ( @d1 ) ) . to be_truthy
580
+ expect ( @b1 . ancestor_of? ( @d1 ) ) . to be_truthy
581
+ expect ( @b1 . ancestor_of? ( @c3 ) ) . to be_falsey
582
+ end
583
+
584
+ it "checks descendant of node" do
585
+ expect ( @c1 . descendant_of? ( @a1 ) ) . to be_truthy
586
+ expect ( @d2 . descendant_of? ( @a1 ) ) . to be_truthy
587
+ expect ( @b1 . descendant_of? ( @a2 ) ) . to be_falsey
588
+ end
589
+ end
590
+
554
591
end
You can’t perform that action at this time.
0 commit comments