Files
grecia/spec/components/sdg/goals/icon_component_spec.rb
Javi Martín 8f2150d9db Add SDG Spanish icons in SVG format
Based on an EPS file downloaded from The Global Goals page [1].

Although in that page there are icons for other languages we support and
that we've only got in PNG format, the Spanish ones are the only ones
which are similar to the official PNG ones provided by the UN or
UN-related organizations like UNRIC. Icons in other languages (like
Chinese, French or Russian) are not that similar to the official PNG
icons and their quality is (in my humble opinion) lower.

Since SVG icons are smaller and can be compressed, users browsing the
page in Spanish will have to download about 80KB for the SDG icons,
instead of the 240KB they needed to download when using PNGs.

[1] https://www.globalgoals.org/resources
2021-09-30 15:06:50 +02:00

26 lines
786 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.svg"
end
it "returns a PNG icon when it isn't available in SVG" do
allow(I18n).to receive(:fallbacks).and_return({ en: [:de] })
expect(component.image_path).to eq "sdg/de/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.svg"
end
end
end