blob: 12cd411a613e2866412658129c9599e8c0854c49 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Banzai::Filter::SuggestionFilter, feature_category: :team_planning do
include FilterSpecHelper
let(:input) { %(<pre class="code highlight js-syntax-highlight language-suggestion"><code>foo\n</code></pre>) }
let(:default_context) do
{ suggestions_filter_enabled: true }
end
it 'includes `js-render-suggestion` class' do
doc = filter(input, default_context)
result = doc.css('code').first
expect(result[:class]).to include('js-render-suggestion')
end
it 'includes no `js-render-suggestion` when filter is disabled' do
doc = filter(input)
result = doc.css('code').first
expect(result[:class]).to be_nil
end
context 'multi-line suggestions' do
let(:data_attr) { Banzai::Filter::CodeLanguageFilter::LANG_PARAMS_ATTR }
let(:input) { %(<pre class="code highlight js-syntax-highlight language-suggestion" #{data_attr}="-3+2"><code>foo\n</code></pre>) }
it 'element has correct data-lang-params' do
doc = filter(input, default_context)
pre = doc.css('pre').first
expect(pre[data_attr]).to eq('-3+2')
end
end
end
|