0cd73885e6
Closes #1521
33 lines
1.6 KiB
Ruby
33 lines
1.6 KiB
Ruby
require 'spec_helper'
|
|
|
|
describe BlobHelper do
|
|
describe 'highlight' do
|
|
let(:blob_name) { 'test.lisp' }
|
|
let(:no_context_content) { ":type \"assem\"))" }
|
|
let(:blob_content) { "(make-pathname :defaults name\n#{no_context_content}" }
|
|
let(:split_content) { blob_content.split("\n") }
|
|
|
|
it 'should return plaintext for unknown lexer context' do
|
|
result = highlight(blob_name, no_context_content, nowrap: true, continue: false)
|
|
expect(result).to eq('<span id="LC1" class="line">:type "assem"))</span>')
|
|
end
|
|
|
|
it 'should highlight single block' do
|
|
expected = %Q[<span id="LC1" class="line"><span class="p">(</span><span class="nb">make-pathname</span> <span class="ss">:defaults</span> <span class="nv">name</span></span>
|
|
<span id="LC2" class="line"><span class="ss">:type</span> <span class="s">"assem"</span><span class="p">))</span></span>]
|
|
|
|
expect(highlight(blob_name, blob_content, nowrap: true, continue: false)).to eq(expected)
|
|
end
|
|
|
|
it 'should highlight continued blocks' do
|
|
# Both lines have LC1 as ID since formatter doesn't support continue at the moment
|
|
expected = [
|
|
'<span id="LC1" class="line"><span class="p">(</span><span class="nb">make-pathname</span> <span class="ss">:defaults</span> <span class="nv">name</span></span>',
|
|
'<span id="LC1" class="line"><span class="ss">:type</span> <span class="s">"assem"</span><span class="p">))</span></span>'
|
|
]
|
|
|
|
result = split_content.map{ |content| highlight(blob_name, content, nowrap: true, continue: true) }
|
|
expect(result).to eq(expected)
|
|
end
|
|
end
|
|
end
|