Sha256: ccc59334951d54453d43e15c9331a23f04dd68a9dbc70b394774df12b0634fe0
Contents?: true
Size: 1.39 KB
Versions: 15
Compression:
Stored size: 1.39 KB
Contents
require 'inline_svg/transform_pipeline' describe InlineSvg::TransformPipeline::Transformations::DataAttributes do it "adds a data attribute to a SVG document" do document = Nokogiri::XML::Document.parse('<svg>Some document</svg>') transformation = InlineSvg::TransformPipeline::Transformations::DataAttributes.create_with_value({some: "value"}) expect(transformation.transform(document).to_html).to eq( "<svg data-some=\"value\">Some document</svg>\n" ) end context "when multiple data attributes are supplied" do it "adds data attributes to the SVG for each supplied value" do document = Nokogiri::XML::Document.parse('<svg>Some document</svg>') transformation = InlineSvg::TransformPipeline::Transformations::DataAttributes. create_with_value({some: "value", other: "thing"}) expect(transformation.transform(document).to_html).to eq( "<svg data-some=\"value\" data-other=\"thing\">Some document</svg>\n" ) end end context "when a non-hash is supplied" do it "does not update the SVG document" do document = Nokogiri::XML::Document.parse('<svg>Some document</svg>') transformation = InlineSvg::TransformPipeline::Transformations::DataAttributes. create_with_value("some non-hash") expect(transformation.transform(document).to_html).to eq( "<svg>Some document</svg>\n" ) end end end
Version data entries
15 entries across 15 versions & 1 rubygems