Skip to content

Commit a510241

Browse files
committed
added spec for relationship methods
1 parent 1be9db6 commit a510241

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

spec/label_spec.rb

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -551,4 +551,41 @@ def roots_name_and_order
551551
expect(tree[@b]).to eq({})
552552
end
553553
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+
554591
end

0 commit comments

Comments
 (0)