Skip to content

Commit

Permalink
Test source_location
Browse files Browse the repository at this point in the history
  • Loading branch information
zyc9012 committed Apr 3, 2023
1 parent 905799a commit 56f89c2
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions spec/patch_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,26 @@
_(@the_template.clone.children.size).must_equal 1
end
end

describe "source_location" do
before do
@doc = Nokolexbor::HTML('<body><!--comment--><div class="a">123</div></body>')
end

it 'element' do
_(@doc.at_css('div').source_location).must_equal 21
end

it 'text node' do
_(@doc.at_css('::text').source_location).must_equal 35
end

it 'comment' do
_(@doc.at_css('body').child.source_location).must_equal 10
end

it 'attribute' do
_(@doc.at_css('div').attribute('class').source_location).must_equal 25
end
end
end

0 comments on commit 56f89c2

Please sign in to comment.