2016-01-29 22:53:50 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
describe Gitlab::Diff::InlineDiffMarker do
|
|
|
|
describe '#mark' do
|
2018-03-17 18:26:18 +05:30
|
|
|
let(:inline_diffs) { [2..5] }
|
|
|
|
let(:raw) { "abc 'def'" }
|
|
|
|
|
|
|
|
subject { described_class.new(raw, rich).mark(inline_diffs) }
|
|
|
|
|
2016-04-02 18:10:28 +05:30
|
|
|
context "when the rich text is html safe" do
|
|
|
|
let(:rich) { %{<span class="abc">abc</span><span class="space"> </span><span class="def">'def'</span>}.html_safe }
|
2016-01-29 22:53:50 +05:30
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
it 'marks the range' do
|
|
|
|
expect(subject).to eq(%{<span class="abc">ab<span class="idiff left">c</span></span><span class="space"><span class="idiff"> </span></span><span class="def"><span class="idiff right">'d</span>ef'</span>})
|
2016-04-02 18:10:28 +05:30
|
|
|
expect(subject).to be_html_safe
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-02-15 15:39:39 +05:30
|
|
|
context "when the text is not html safe" do
|
2018-03-17 18:26:18 +05:30
|
|
|
let(:rich) { "abc 'def' differs" }
|
2016-04-02 18:10:28 +05:30
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
it 'marks the range' do
|
2018-03-17 18:26:18 +05:30
|
|
|
expect(subject).to eq(%{ab<span class="idiff left right">c 'd</span>ef' differs})
|
2016-04-02 18:10:28 +05:30
|
|
|
expect(subject).to be_html_safe
|
|
|
|
end
|
2016-01-29 22:53:50 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|