summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab/markdown/syntax_highlight_filter_spec.rb
blob: f9be5ad2a6eac17480de0904845e01820cdc1f9e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
require 'spec_helper'

module Gitlab::Markdown
  describe SyntaxHighlightFilter, lib: true do
    include FilterSpecHelper

    it 'highlights valid code blocks' do
      result = filter('<pre><code>def fun end</code>')
      expect(result.to_html).to eq("<pre class=\"code highlight js-syntax-highlight plaintext\"><code>def fun end</code></pre>\n")
    end

    it 'passes through invalid code blocks' do
      allow_any_instance_of(SyntaxHighlightFilter).to receive(:block_code).and_raise(StandardError)

      result = filter('<pre><code>This is a test</code></pre>')
      expect(result.to_html).to eq('<pre>This is a test</pre>')
    end
  end
end