From 221cb6a6c185ea794284da517a6821910d3c2c79 Mon Sep 17 00:00:00 2001 From: Georg Gadinger Date: Thu, 16 Feb 2023 20:35:06 +0100 Subject: [PATCH] add view specs for inbox/_actions.html --- spec/views/inbox/_actions.html.haml_spec.rb | 52 +++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 spec/views/inbox/_actions.html.haml_spec.rb diff --git a/spec/views/inbox/_actions.html.haml_spec.rb b/spec/views/inbox/_actions.html.haml_spec.rb new file mode 100644 index 00000000..86300855 --- /dev/null +++ b/spec/views/inbox/_actions.html.haml_spec.rb @@ -0,0 +1,52 @@ +# frozen_string_literal: true + +require "rails_helper" + +describe "inbox/_actions.html.haml", type: :view do + let(:delete_id) { "ib-delete-all" } + let(:disabled) { false } + + let(:user) { FactoryBot.create(:user) } + + before do + sign_in user + end + + subject(:rendered) do + render partial: "inbox/actions", locals: { + delete_id:, + disabled:, + inbox_count: 4020, + } + end + + it "has a button for deleting all inbox entries" do + html = Nokogiri::HTML.parse(rendered) + button = html.css("button#ib-delete-all") + + expect(button.attr("disabled")).to be_nil + expect(button.attr("data-ib-count").value).to eq "4020" + end + + context "with disabled = true" do + let(:disabled) { true } + + it "has a button for deleting all inbox entries" do + html = Nokogiri::HTML.parse(rendered) + button = html.css("button#ib-delete-all") + + expect(button.attr("disabled").value).to be_truthy + end + end + + context "with delete_id = ib-delete-all-author" do + let(:delete_id) { "ib-delete-all-author" } + + it "has a button for deleting all inbox entries" do + html = Nokogiri::HTML.parse(rendered) + button = html.css("button#ib-delete-all-author") + + expect(button.attr("data-ib-count").value).to eq "4020" + end + end +end