# 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 ''
end
it 'replaces nomnoml 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("[Pirate|eyeCount: Int|raid();pillage()|\n [beard]--[parrot]\n [beard]-:>[foul mouth]\n]
")
expect(doc.to_s).to eq ''
end
it 'does not replace nomnoml pre tag with img tag if kroki is disabled' do
stub_application_setting(kroki_enabled: false)
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]
"
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
end