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

Version Path
inline_svg-0.11.0 spec/transformation_pipeline/transformations/data_attributes_spec.rb
inline_svg-0.10.0 spec/transformation_pipeline/transformations/data_attributes_spec.rb
inline_svg-0.9.1 spec/transformation_pipeline/transformations/data_attributes_spec.rb
inline_svg-0.9.0 spec/transformation_pipeline/transformations/data_attributes_spec.rb
inline_svg-0.8.0 spec/transformation_pipeline/transformations/data_attributes_spec.rb
inline_svg-0.7.0 spec/transformation_pipeline/transformations/data_attributes_spec.rb
inline_svg-0.6.4 spec/transformation_pipeline/transformations/data_attributes_spec.rb
inline_svg-0.6.3 spec/transformation_pipeline/transformations/data_attributes_spec.rb
inline_svg-0.6.2 spec/transformation_pipeline/transformations/data_attributes_spec.rb
inline_svg-0.6.1 spec/transformation_pipeline/transformations/data_attributes_spec.rb
inline_svg-0.6.0 spec/transformation_pipeline/transformations/data_attributes_spec.rb
inline_svg-0.5.3 spec/transformation_pipeline/transformations/data_attributes_spec.rb
inline_svg-0.5.2 spec/transformation_pipeline/transformations/data_attributes_spec.rb
inline_svg-0.5.1 spec/transformation_pipeline/transformations/data_attributes_spec.rb
inline_svg-0.5.0 spec/transformation_pipeline/transformations/data_attributes_spec.rb