# frozen_string_literal: true require "rails_helper" describe BootstrapHelper, type: :helper do include ActiveSupport::Testing::TimeHelpers describe "#nav_entry" do it "should return a HTML navigation item which links to a given address" do allow(self).to receive(:current_page?).and_return(false) expect(nav_entry("Example", "/example")).to( eq(''), ) end it "should return with an active attribute if the link matches the current URL" do allow(self).to receive(:current_page?).and_return(true) expect(nav_entry("Example", "/example")).to( eq(''), ) end it "should include an icon if given" do allow(self).to receive(:current_page?).and_return(false) expect(nav_entry("Example", "/example", icon: "beaker")).to( eq(''), ) end it "should only include an icon if wanted" do allow(self).to receive(:current_page?).and_return(false) expect(nav_entry("Example", "/example", icon: "beaker", icon_only: true)).to( eq(''), ) end it "should include a badge if given" do allow(self).to receive(:current_page?).and_return(false) expect(nav_entry("Example", "/example", badge: 3)).to( eq(''), ) expect(nav_entry("Example", "/example", badge: 3, badge_color: "primary", badge_pill: true)).to( eq(''), ) end it "should put an ID on the entry an id if given" do allow(self).to receive(:current_page?).and_return(false) expect(nav_entry("Example", "/example", id: "testing")).to( eq("
  • Example
  • "), ) end end describe "#list_group_item" do it "should return a HTML navigation item which links to a given address" do allow(self).to receive(:current_page?).and_return(false) expect(list_group_item("Example", "/example")).to( eq('Example'), ) end it "should return with an active attribute if the link matches the current URL" do allow(self).to receive(:current_page?).and_return(true) expect(list_group_item("Example", "/example")).to( eq('Example'), ) end it "should include a badge if given" do allow(self).to receive(:current_page?).and_return(false) expect(list_group_item("Example", "/example", badge: 3)).to( eq('Example 3'), ) end end describe "#bootstrap_color" do it "should map error and alert to danger" do expect(bootstrap_color("error")).to eq("danger") expect(bootstrap_color("alert")).to eq("danger") end it "should map notice to info" do expect(bootstrap_color("notice")).to eq("info") end it "should return any uncovered value" do expect(bootstrap_color("success")).to eq("success") end end describe "#tooltip" do it "should return the proper markup" do expect(tooltip("Example Text", "This is in a tooltip")).to eq("Example Text") end end describe "#time_tooltip" do it "should return a tooltip with proper time values" do travel_to(Time.utc(1984)) do @user = FactoryBot.create(:user) travel 10.minutes expect(time_tooltip(@user)).to eq("10 minutes") end end end describe "#hidespan" do it "should return the proper markup" do expect(hidespan("Hidden Text", "d-none")).to eq("Hidden Text") end end end