Files
nairobi/spec/components/sdg/goals/index_component_spec.rb
2021-09-08 12:39:36 +02:00

39 lines
1.1 KiB
Ruby

require "rails_helper"
describe SDG::Goals::IndexComponent do
let!(:goals) { SDG::Goal.all }
let!(:phases) { SDG::Phase.all }
let!(:component) { SDG::Goals::IndexComponent.new(goals, header: nil, phases: phases) }
before do
Setting["feature.sdg"] = true
end
describe "header" do
it "renders the default header when a custom one is not defined" do
render_inline component
expect(page).to have_css "h1", exact_text: "Sustainable Development Goals"
end
it "renders a custom header" do
sdg_web_section = WebSection.find_by!(name: "sdg")
header = create(:widget_card, cardable: sdg_web_section)
component = SDG::Goals::IndexComponent.new(goals, header: header, phases: phases)
render_inline component
expect(page).to have_content header.title
expect(page).not_to have_css "h1", exact_text: "Sustainable Development Goals"
end
end
it "renders phases" do
render_inline component
expect(page).to have_content "Sensitization"
expect(page).to have_content "Planning"
expect(page).to have_content "Monitoring"
end
end