# frozen_string_literal: true require 'spec_helper' RSpec.describe Banzai::Filter::KrokiFilter do include FilterSpecHelper it 'replaces nomnoml pre tag with img tag if kroki is enabled' do stub_application_setting(kroki_enabled: true, kroki_url: "http://localhost:8000") doc = filter("
[Pirate|eyeCount: Int|raid();pillage()|\n [beard]--[parrot]\n [beard]-:>[foul mouth]\n]
")
expect(doc.to_s).to eq '[Pirate|eyeCount: Int|raid();pillage()|\n [beard]--[parrot]\n [beard]-:>[foul mouth]\n]
")
expect(doc.to_s).to eq '[Pirate|eyeCount: Int|raid();pillage()|\n [beard]--[parrot]\n [beard]-:>[foul mouth]\n]
")
expect(doc.to_s).to eq "[Pirate|eyeCount: Int|raid();pillage()|\n [beard]--[parrot]\n [beard]-:>[foul mouth]\n]
"
end
it 'does not replace plantuml pre tag with img tag if both kroki and plantuml are enabled' do
stub_application_setting(kroki_enabled: true,
kroki_url: "http://localhost:8000",
plantuml_enabled: true,
plantuml_url: "http://localhost:8080")
doc = filter("Bob->Alice : hello
")
expect(doc.to_s).to eq 'Bob->Alice : hello
'
end
it 'adds hidden attribute when content size is large' do
stub_application_setting(kroki_enabled: true, kroki_url: "http://localhost:8000")
text = '[Pirate|eyeCount: Int|raid();pillage()|\n [beard]--[parrot]\n [beard]-:>[foul mouth]\n]' * 25
doc = filter("#{text}
")
expect(doc.to_s).to start_with '