require 'rails_helper' require 'html_normalize' describe PrettyText do def n(html) HtmlNormalize.normalize(html) end context 'markdown it' do before do SiteSetting.enable_experimental_markdown_it = true end it 'works correctly for new vs old engine with trivial cases' do md = <<~MD [poll] 1. test 1 2. test 2 [/poll] MD new_engine = n(PrettyText.cook(md)) SiteSetting.enable_experimental_markdown_it = false old_engine = n(PrettyText.cook(md)) expect(new_engine).to eq(old_engine) end it 'does not break poll options when going from loose to tight' do md = <<~MD [poll type=multiple] 1. test 1 :) test 2. test 2 [/poll] MD tight_cooked = PrettyText.cook(md) md = <<~MD [poll type=multiple] 1. test 1 :) test 2. test 2 [/poll] MD loose_cooked = PrettyText.cook(md) tight_hashes = tight_cooked.scan(/data-poll-option-id=['"]([^'"]+)/) loose_hashes = loose_cooked.scan(/data-poll-option-id=['"]([^'"]+)/) expect(tight_hashes).to eq(loose_hashes) end it 'can correctly cook polls' do md = <<~MD [poll type=multiple] 1. test 1 :) test 2. test 2 [/poll] MD cooked = PrettyText.cook md expected = <<~MD
0 voters
Choose up to 2 options