These icons have been downloaded from The Global Goals page [1]. English is the official language of this page and the only one containing all the information. Since SVG icons are smaller and can be compressed, users browsing the page in English will have to download about 45KB for the SDG icons, instead of the 250KB they needed to download when using PNGs. [1] https://globalgoals.org
26 lines
786 B
Ruby
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.png"
|
|
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
|