# frozen_string_literal: true

require './lib/kindguardian/html'

# frozen_string_literal: true

RSpec.describe Kindguardian::Html do
  describe '#remove_html_tags_with_classes' do
    it 'removes html tags with specific classes' do
      expect(described_class.remove_html_tags_with_classes('<div class="test">test</div>', 'test'))
        .to eq "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\" \"http://www.w3.org/TR/REC-html40/loose.dtd\">\n<html><body><div class=\"test\">test</div></body></html>\n"
    end
  end

  describe '#format_figcaptions' do
    it 'returns formatted figcaptions' do
      expect(described_class.format_figcaptions('<figcaption>figure</figcaption>'))
        .to eq '<figcaption><small><strong>figure</strong></small></figcaption>'
    end
  end

  describe '#fix_lists' do
    it 'returns clean lists' do
      expect(described_class.fix_lists('<li><p>list</p></li>'))
        .to eq '<li>list</li>'
    end
  end

  describe '#format_blockquotes' do
    it 'returns formatted blockquote' do
      expect(described_class.format_blockquotes('<blockquote>block</blockquote>'))
        .to eq '<blockquote><em><strong>block</strong></em></blockquote>'
    end
  end

  describe '#sanitize_html' do
    it 'returns sanitized html' do
      expect(described_class.sanitize_html('<div><something>test</something></div>'))
        .to eq '<html><div>test</div></html>'
    end
  end
end
