BigW Consortium Gitlab

inline_diff_marker_spec.rb 1000 Bytes
Newer Older
Douwe Maan committed
1 2
require 'spec_helper'

3
describe Gitlab::Diff::InlineDiffMarker do
4
  describe '#mark' do
5 6 7 8 9
    let(:inline_diffs) { [2..5] }
    let(:raw) { "abc 'def'" }

    subject { described_class.new(raw, rich).mark(inline_diffs) }

10 11
    context "when the rich text is html safe" do
      let(:rich) { %{<span class="abc">abc</span><span class="space"> </span><span class="def">&#39;def&#39;</span>}.html_safe }
Douwe Maan committed
12

13 14
      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">&#39;d</span>ef&#39;</span>})
15 16 17 18 19
        expect(subject).to be_html_safe
      end
    end

    context "when the text text is not html safe" do
20
      let(:rich) { "abc 'def' differs" }
21

22
      it 'marks the range' do
23
        expect(subject).to eq(%{ab<span class="idiff left right">c &#39;d</span>ef&#39; differs})
24 25
        expect(subject).to be_html_safe
      end
Douwe Maan committed
26 27 28
    end
  end
end