Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/lib/banzai/filter/markdown_filter_spec.rb')
-rw-r--r--spec/lib/banzai/filter/markdown_filter_spec.rb57
1 files changed, 23 insertions, 34 deletions
diff --git a/spec/lib/banzai/filter/markdown_filter_spec.rb b/spec/lib/banzai/filter/markdown_filter_spec.rb
index 64d65528426..251e6efe50b 100644
--- a/spec/lib/banzai/filter/markdown_filter_spec.rb
+++ b/spec/lib/banzai/filter/markdown_filter_spec.rb
@@ -23,54 +23,43 @@ RSpec.describe Banzai::Filter::MarkdownFilter, feature_category: :team_planning
end
describe 'code block' do
- context 'using CommonMark' do
- before do
- stub_const('Banzai::Filter::MarkdownFilter::DEFAULT_ENGINE', :common_mark)
- end
+ it 'adds language to lang attribute when specified' do
+ result = filter("```html\nsome code\n```", no_sourcepos: true)
- it 'adds language to lang attribute when specified' do
- result = filter("```html\nsome code\n```", no_sourcepos: true)
-
- expect(result).to start_with('<pre lang="html"><code>')
- end
+ expect(result).to start_with('<pre lang="html"><code>')
+ end
- it 'does not add language to lang attribute when not specified' do
- result = filter("```\nsome code\n```", no_sourcepos: true)
+ it 'does not add language to lang attribute when not specified' do
+ result = filter("```\nsome code\n```", no_sourcepos: true)
- expect(result).to start_with('<pre><code>')
- end
+ expect(result).to start_with('<pre><code>')
+ end
- it 'works with utf8 chars in language' do
- result = filter("```日\nsome code\n```", no_sourcepos: true)
+ it 'works with utf8 chars in language' do
+ result = filter("```日\nsome code\n```", no_sourcepos: true)
- expect(result).to start_with('<pre lang="日"><code>')
- end
+ expect(result).to start_with('<pre lang="日"><code>')
+ end
- it 'works with additional language parameters' do
- result = filter("```ruby:red gem foo\nsome code\n```", no_sourcepos: true)
+ it 'works with additional language parameters' do
+ result = filter("```ruby:red gem foo\nsome code\n```", no_sourcepos: true)
- expect(result).to start_with('<pre lang="ruby:red" data-meta="gem foo"><code>')
- end
+ expect(result).to include('lang="ruby:red"')
+ expect(result).to include('data-meta="gem foo"')
end
end
describe 'source line position' do
- context 'using CommonMark' do
- before do
- stub_const('Banzai::Filter::MarkdownFilter::DEFAULT_ENGINE', :common_mark)
- end
-
- it 'defaults to add data-sourcepos' do
- result = filter('test')
+ it 'defaults to add data-sourcepos' do
+ result = filter('test')
- expect(result).to eq '<p data-sourcepos="1:1-1:4">test</p>'
- end
+ expect(result).to eq '<p data-sourcepos="1:1-1:4">test</p>'
+ end
- it 'disables data-sourcepos' do
- result = filter('test', no_sourcepos: true)
+ it 'disables data-sourcepos' do
+ result = filter('test', no_sourcepos: true)
- expect(result).to eq '<p>test</p>'
- end
+ expect(result).to eq '<p>test</p>'
end
end