The layer kit (spec/04 §3): the checks every layer kind passes, as every component
passes Macaw.Component.Conformance, and shaped the same way.
It ships in lib/ so a package author runs it in their own CI. check(check, kind, opts) answers one check's findings, [] for a kind that passes; check(kind, opts)
runs every check of checks/0; format/1 words a finding as one line; use Macaw.Frame.LayerKit, kind: … writes one test per check. A misuse of the kit (an unknown
check, a module that is not a kind, bad fixtures) is a finding {:kit, {path, fault}},
never a raise. The kit renders through the scene and the SVG renderer (spec/10) and
reads the SVG's tags and attributes itself (lazy_html is not a dependency). The canvas
targets join :golden when they are registered (proposal #12); until then it compares
the SVG alone.
Fixtures
A kind ships a fixture set (fixtures:, else the kind's fixtures/0 when it exports
one): one fixture per distinct shape of its declarations, and at least one per model it
draws in. A fixture is %{name, layer, model, rows, schema, size} (and optionally
theme, served): the layer node; the frame node its model realizes from (%{kind: "cartesian", scales: …}); the rows, a Macaw.Data.Table or row maps (the kit also
builds the same rows as a chunked table of several chunks); the slot's
Macaw.Data.Schema or nil; the size {width, height}. Both built-in themes run
(Macaw.Layers.Theme.default/0 and dark/0) unless the fixture names one.
The checks, in order
:declarations, :validation, :socketless, :budget, :summary, :theme_roles,
:no_inline_style, :columns, :no_decode, :series, :never_raises, :golden: each as spec/04
§3's table says. Findings are {check, {where, what}}, where naming the fixture, the
model, the renderer and the theme: {:columns, {{"fixture 2", :polar, :svg, :default}, {:row_read, :get, 412}}}.
Options
fixtures:the fixture set;goldens:the directory the:goldencheck reads,test/support/golden/layersby default, each fixture's SVG at<kind>/<fixture>-<theme>.svg;write: truerecords them instead (a deliberate regeneration);registry:the frame document's registry the:validationcheck validates through (Macaw.Frame.Layers.document/1of[]with the kind added).
Summary
Types
A finding of the kit (§3).
Where a finding is: the fixture, the model, the renderer and the theme.
Functions
Every check's findings for a kind (§3): [] for a kind that passes every one.
One check's findings for a kind (§3); an unknown check is a kit finding.
The kit's checks, in order.
A finding as one line.
Types
Functions
Every check's findings for a kind (§3): [] for a kind that passes every one.
One check's findings for a kind (§3); an unknown check is a kit finding.
@spec checks() :: [atom(), ...]
The kit's checks, in order.
A finding as one line.
iex> Macaw.Frame.LayerKit.format({:columns, {{"fixture 2", :polar, :svg, :default}, {:row_read, :get, 412}}})
"columns: fixture 2 (polar, svg, default): {:row_read, :get, 412}"
iex> Macaw.Frame.LayerKit.format({:kit, {[:check], {:unknown, :check, :nope}}})
"kit: check: {:unknown, :check, :nope}"