# frozen_string_literal: true require "test_helper" class ActionText::FormHelperTest < ActionView::TestCase tests ActionText::TagHelper def form_with(*) @output_buffer = super end teardown do I18n.backend.reload! end setup do I18n.backend.store_translations("placeholder", activerecord: { attributes: { message: { title: "Story title" } } } ) end test "form with rich text area" do form_with model: Message.new, scope: :message do |form| form.rich_text_area :content end assert_dom_equal \ '
' \ '' \ '' \ "" \ "
", output_buffer end test "form with rich text area having class" do form_with model: Message.new, scope: :message do |form| form.rich_text_area :content, class: "custom-class" end assert_dom_equal \ '
' \ '' \ '' \ "" \ "
", output_buffer end test "form with rich text area for non-attribute" do form_with model: Message.new, scope: :message do |form| form.rich_text_area :not_an_attribute end assert_dom_equal \ '
' \ '' \ '' \ "" \ "
", output_buffer end test "modelless form with rich text area" do form_with url: "/messages", scope: :message do |form| form.rich_text_area :content end assert_dom_equal \ '
' \ '' \ '' \ "" \ "
", output_buffer end test "form with rich text area having placeholder without locale" do form_with model: Message.new, scope: :message do |form| form.rich_text_area :content, placeholder: true end assert_dom_equal \ '
' \ '' \ '' \ "" \ "
", output_buffer end test "form with rich text area having placeholder with locale" do I18n.with_locale :placeholder do form_with model: Message.new, scope: :message do |form| form.rich_text_area :title, placeholder: true end end assert_dom_equal \ '
' \ '' \ '' \ "" \ "
", output_buffer end end