Sha256: b990f1675fd32819d393eee744abb7f283e367ce02e74087f294e38e35852bc6
Contents?: true
Size: 1.92 KB
Versions: 2
Compression:
Stored size: 1.92 KB
Contents
require 'inline_svg/transform_pipeline' describe InlineSvg::TransformPipeline::Transformations::AriaAttributes do it "adds a role attribute to the SVG document" do document = Nokogiri::XML::Document.parse('<svg>Some document</svg>') transformation = InlineSvg::TransformPipeline::Transformations::AriaAttributes.create_with_value({}) expect(transformation.transform(document).to_html).to eq( "<svg role=\"img\">Some document</svg>\n" ) end context "aria-labelledby attribute" do it "adds 'title' when a title element is present" do document = Nokogiri::XML::Document.parse('<svg><title>Some title</title>Some document</svg>') transformation = InlineSvg::TransformPipeline::Transformations::AriaAttributes.create_with_value({}) expect(transformation.transform(document).to_html).to eq( "<svg role=\"img\" aria-labelledby=\"title\"><title>Some title</title>Some document</svg>\n" ) end it "adds 'desc' when a description element is present" do document = Nokogiri::XML::Document.parse('<svg><desc>Some description</desc>Some document</svg>') transformation = InlineSvg::TransformPipeline::Transformations::AriaAttributes.create_with_value({}) expect(transformation.transform(document).to_html).to eq( "<svg role=\"img\" aria-labelledby=\"desc\"><desc>Some description</desc>Some document</svg>\n" ) end it "adds both 'desc' and 'title' when title and description elements are present" do document = Nokogiri::XML::Document.parse('<svg><title>Some title</title><desc>Some description</desc>Some document</svg>') transformation = InlineSvg::TransformPipeline::Transformations::AriaAttributes.create_with_value({}) expect(transformation.transform(document).to_html).to eq( "<svg role=\"img\" aria-labelledby=\"title desc\"><title>Some title</title>\n<desc>Some description</desc>Some document</svg>\n" ) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
inline_svg-0.8.0 | spec/transformation_pipeline/aria_attributes_spec.rb |
inline_svg-0.7.0 | spec/transformation_pipeline/aria_attributes_spec.rb |