Files
grecia/spec/components/sdg/goals/icon_component_spec.rb
Javi Martín ceed3c18d3 Display SDG icons alongside tags
We're using the translation fallbacks for the icons, just like we do for
texts.

Note we use the `render?` method provided by view_component to make sure
the component will not be rendered when certain features are disabled.

Also note the `find_asset` method works differently in development and
production, and so we use different approaches here.
2021-01-09 14:53:54 +01:00

20 lines
586 B
Ruby

require "rails_helper"
describe SDG::Goals::IconComponent do
describe "#image_path" do
let(:component) { SDG::Goals::IconComponent.new(SDG::Goal[8]) }
it "returns icons for the first fallback language with icons" do
allow(I18n).to receive(:fallbacks).and_return({ en: [:es, :de] })
expect(component.image_path).to eq "sdg/es/goal_8.png"
end
it "returns the default icons when no fallback language has icons" do
allow(I18n).to receive(:fallbacks).and_return({})
expect(component.image_path).to eq "sdg/default/goal_8.png"
end
end
end