From 869d25b7d38525a3e6209281b8f3548bb3afc3b9 Mon Sep 17 00:00:00 2001
From: Arpit Jalan <arpit@techapj.com>
Date: Sat, 16 Jan 2021 19:35:19 +0530
Subject: [PATCH] DEV: add specs for Vanilla import script improvements
 (#11712)

---
 .../import_scripts/vanilla_body_parser_spec.rb | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

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 }