Skip to content

A platform for community discussion. Free, open, simple.

DEV: add specs for Vanilla import script improvements (#11712)

Arpit Jalan869d25b7d385
diff --git a/spec/script/import_scripts/vanilla_body_parser_spec.rb b/spec/script/import_scripts/vanilla_body_parser_spec.rb
index f01ce76c6be..d0a3dd32eb1 100644
--- a/spec/script/import_scripts/vanilla_body_parser_spec.rb
+++ b/spec/script/import_scripts/vanilla_body_parser_spec.rb
@@ -37,6 +37,24 @@ describe VanillaBodyParser do
this starts with spaces but IS NOT a quote'''
end
+ it 'replaces pre tags with code backticks' do
+ complex_html = '<pre class="CodeBlock">foobar</pre>'
+ parsed = VanillaBodyParser.new({ 'Format' => 'Html', 'Body' => complex_html }, user_id).parse
+ expect(parsed).to eq "\n```\nfoobar\n```\n"
+ end
+
+ it 'strips code tags' do
+ complex_html = '<code>foobar</code>'
+ parsed = VanillaBodyParser.new({ 'Format' => 'Html', 'Body' => complex_html }, user_id).parse
+ expect(parsed).to eq "foobar"
+ end
+
+ it 'replaces div with quote class to bbcode quotes' do
+ complex_html = '<div class="Quote">foobar</div>'
+ parsed = VanillaBodyParser.new({ 'Format' => 'Html', 'Body' => complex_html }, user_id).parse
+ expect(parsed).to eq "\n\n[quote]\n\nfoobar\n\n[/quote]\n\n"
+ end
+
describe 'rich format' do
let(:rich_bodies) { JSON.parse(File.read('spec/fixtures/json/vanilla-rich-posts.json')).deep_symbolize_keys }