Skip to content
Snippets Groups Projects
Commit 1223c923 authored by Douwe Maan's avatar Douwe Maan
Browse files

Update specs

parent 134c848c
No related branches found
No related tags found
No related merge requests found
require 'spec_helper' require 'spec_helper'
   
describe Gitlab::Diff::InlineDiffMarker, lib: true do describe Gitlab::Diff::InlineDiffMarker, lib: true do
describe '#inline_diffs' do describe '#mark' do
context "when the rich text is html safe" do context "when the rich text is html safe" do
let(:raw) { "abc 'def'" } let(:raw) { "abc <def>" }
let(:rich) { %{<span class="abc">abc</span><span class="space"> </span><span class="def">&#39;def&#39;</span>}.html_safe } let(:rich) { %{<span class="abc">abc</span><span class="space"> </span><span class="def">&lt;def&gt;</span>}.html_safe }
let(:inline_diffs) { [2..5] } let(:inline_diffs) { [2..5] }
let(:subject) { Gitlab::Diff::InlineDiffMarker.new(raw, rich).mark(inline_diffs) } let(:subject) { described_class.new(raw, rich).mark(inline_diffs) }
   
it 'marks the inline diffs' do it 'marks the inline diffs' 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>}) 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'>&lt;d</span>ef&gt;</span>})
expect(subject).to be_html_safe expect(subject).to be_html_safe
end end
end end
   
context "when the text text is not html safe" do context "when the text is not html safe" do
let(:raw) { "abc 'def'" } let(:raw) { "abc <def>" }
let(:inline_diffs) { [2..5] } let(:inline_diffs) { [2..5] }
let(:subject) { Gitlab::Diff::InlineDiffMarker.new(raw).mark(inline_diffs) } let(:subject) { described_class.new(raw).mark(inline_diffs) }
   
it 'marks the inline diffs' do it 'marks the inline diffs' do
expect(subject).to eq(%{ab<span class='idiff left right'>c &#39;d</span>ef&#39;}) expect(subject).to eq(%{ab<span class='idiff left right'>c &lt;d</span>ef&gt;})
expect(subject).to be_html_safe expect(subject).to be_html_safe
end end
end end
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment