summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab/word_diff/chunk_collection_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/lib/gitlab/word_diff/chunk_collection_spec.rb')
-rw-r--r--spec/lib/gitlab/word_diff/chunk_collection_spec.rb23
1 files changed, 23 insertions, 0 deletions
diff --git a/spec/lib/gitlab/word_diff/chunk_collection_spec.rb b/spec/lib/gitlab/word_diff/chunk_collection_spec.rb
index aa837f760c1..73e9ff3974a 100644
--- a/spec/lib/gitlab/word_diff/chunk_collection_spec.rb
+++ b/spec/lib/gitlab/word_diff/chunk_collection_spec.rb
@@ -41,4 +41,27 @@ RSpec.describe Gitlab::WordDiff::ChunkCollection do
expect(collection.content).to eq('')
end
end
+
+ describe '#marker_ranges' do
+ let(:chunks) do
+ [
+ Gitlab::WordDiff::Segments::Chunk.new(' Hello '),
+ Gitlab::WordDiff::Segments::Chunk.new('-World'),
+ Gitlab::WordDiff::Segments::Chunk.new('+GitLab'),
+ Gitlab::WordDiff::Segments::Chunk.new('+!!!')
+ ]
+ end
+
+ it 'returns marker ranges for every chunk with changes' do
+ chunks.each { |chunk| collection.add(chunk) }
+
+ expect(collection.marker_ranges).to eq(
+ [
+ Gitlab::MarkerRange.new(6, 10, mode: :deletion),
+ Gitlab::MarkerRange.new(11, 16, mode: :addition),
+ Gitlab::MarkerRange.new(17, 19, mode: :addition)
+ ]
+ )
+ end
+ end
end