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

pathological_markdown_filter_spec.rb « filter « banzai « lib « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: e0a07d1ea7724d2bbfa25390aa64ee42669308f7 (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
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Banzai::Filter::PathologicalMarkdownFilter do
  include FilterSpecHelper

  let_it_be(:short_text) { '![a' * 5 }
  let_it_be(:long_text) { ([short_text] * 10).join(' ') }
  let_it_be(:with_images_text) { "![One ![one](one.jpg) #{'and\n' * 200} ![two ![two](two.jpg)" }

  it 'detects a significat number of unclosed image links' do
    msg = <<~TEXT
      _Unable to render markdown - too many unclosed markdown image links detected._
    TEXT

    expect(filter(long_text)).to eq(msg.strip)
  end

  it 'does nothing when there are only a few unclosed image links' do
    expect(filter(short_text)).to eq(short_text)
  end

  it 'does nothing when there are only a few unclosed image links and images' do
    expect(filter(with_images_text)).to eq(with_images_text)
  end
end