Files
akkounts/spec/components/modal_component_spec.rb

18 lines
668 B
Ruby

require "rails_helper"
RSpec.describe ModalComponent, type: :component do
it "dismisses on background click by default" do
rendered = render_inline(described_class.new) { "Body" }
background = rendered.css("[data-modal-target='background']").first
expect(background["data-action"]).to eq("click->modal#closeBackground")
end
it "can disable background dismissal" do
rendered = render_inline(described_class.new(dismissible: false, card_class: "w-80")) { "Body" }
background = rendered.css("[data-modal-target='background']").first
expect(background["data-action"]).to be_nil
expect(rendered.css(".w-80").any?).to be(true)
end
end