quickdraw/compilation_equivalence_cases/inline_svg.rb

Lines

100%

23 of 23 covered

Branches

—

0 of 0 covered

Methods

100%

3 of 3 covered

1# frozen_string_literal: true
2
31module EquivalenceCases
41 module InlineSvg
51 class InlineSvg < Phlex::HTML
61 def self.equivalence_scenarios
7 {
84 "fragment" => -> (klass) { klass.new.call(fragments: [:f]) },
92 "bad class" => -> (klass) { klass.new(Object.new).call },
10 }
11 end
12
131 def initialize(icon_class = "icon")
1410 @icon_class = icon_class
1510 @d = "M6 18L18 6"
16 end
17
181 def view_template
1910 svg(viewBox: "0 0 24 24", class: "icon") { |s| s.path(d: "M5 13l4 4L19 7") }
205 svg(class: @icon_class) do |s|
214 s.g(fill: "none") do
224 s.circle(cx: 12, cy: 12, r: 3)
238 s.text { "Label <b>" }
248 s.title { :a_symbol }
25 end
264 s.clipPath(id: "c")
27 end
288 svg { |s| s.path(d: @d) }
298 svg { |s| s.plain "text" }
304 svg
314 svg { |_s| } # rubocop:disable Lint/EmptyBlock
3212 fragment(:f) { svg { |s| s.path(d: "in fragment") } }
33 rescue Phlex::ArgumentError
341 plain "rescued"
35 end
36 end
37 end
38end