# frozen_string_literal: true require "test_helper" class ActionText::PlainTextConversionTest < ActiveSupport::TestCase test "
tags are separated by two new lines" do assert_converted_to( "Hello world!\n\nHow are you?", "
Hello world!
How are you?
" ) end test "tags are separated by two new lines" do assert_converted_to( "“Hello world!”\n\n“How are you?”", "Hello world!How are you?" ) end test "tags are separated by two new lines" do assert_converted_to( "Hello world!\n\n1. list1\n\n1. list2\n\nHow are you?", "
Hello world!
- list1
- list2
How are you?
" ) end test "tags are separated by two new lines" do assert_converted_to( "Hello world!\n\n• list1\n\n• list2\n\nHow are you?", "
Hello world!
- list1
- list2
How are you?
" ) end test "tags are separated by two new lines" do assert_converted_to( "Hello world!\n\nHow are you?", "
Hello world!
How are you?" ) end test "- tags are separated by one new line" do assert_converted_to( "• one\n• two\n• three", "
" ) end test "
- one
- two
- three
- tags without a parent list" do assert_converted_to( "• one\n• two\n• three", "
- one
- two
- three
" ) end test "
tags are separated by one new line" do assert_converted_to( "Hello world!\none\ntwo\nthree", "Hello world!
" ) end test "
one
two
threetags are separated by one new line" do assert_converted_to( "Hello world!\nHow are you?", "Hello world!How are you?" ) end test "tags are converted to their plain-text representation" do assert_converted_to( "Hello world! [Cat]", 'Hello world! ' ) end test "preserves non-linebreak whitespace after text" do assert_converted_to( "Hello world!", " Hello world!" ) end test "preserves trailing linebreaks after text" do assert_converted_to( "Hello\nHow are you?", "Hello
How are you?" ) end private def assert_converted_to(plain_text, html) assert_equal plain_text, ActionText::Content.new(html).to_plain_text end end