The component conformance kit (spec/04): the contract and the rendering rules as checks, so a component author proves conformance by running it.
defmodule MyApp.CardsConformanceTest do
use ExUnit.Case, async: true
use Macaw.Component.Conformance,
component: MyApp.Cards,
fixtures: [%{settings: %{"columns" => 2}, deliveries: %{"items" => delivery}}]
endTwo layers. check(check, component, opts) answers one check's findings,
{check, {where, what}} terms, [] for a component that passes; check(component, opts) runs every check, then each check set's; format/1 words a finding. use
writes one test per check. The kit references no ExUnit function itself, so it loads
in production; it is compiled only when lazy_html is present.
A check runs the component's callbacks in the caller's process: a raise is the test's failure, with its stacktrace.
The kit's misuse is a finding, never a raise (#12, #32): an unknown option, check
set or check, a module that isn't a component, and fixtures that aren't a non-empty
list of maps of fixture keys, or whose bindings the context refuses, are
{:kit, {{"options", nil, nil}, fault}}, a fault by option path, every one, judged
before anything renders. use refuses a missing component: or an unknown option
while the test compiles.
Summary
Functions
Writes one test per check, then per check of each set in check_sets:, in a
describe block, each failing with its findings. Takes component: (required) and the
options of check/2.
Every check, then each check set's in check_sets:, over a component.
One check's findings over a component.
The check sets, in order.
The checks of spec/04 §2, in order. The list is the count: a check added here is a row added to the spec's table and a line added below (#13).
A check set's checks, in order: {:ok, checks}, or {:enum, sets} for a name that is
no check set.
A finding as a line a person reads.
Types
Functions
Writes one test per check, then per check of each set in check_sets:, in a
describe block, each failing with its findings. Takes component: (required) and the
options of check/2.
Every check, then each check set's in check_sets:, over a component.
One check's findings over a component.
@spec check_sets() :: [atom()]
The check sets, in order.
@spec checks() :: [atom(), ...]
The checks of spec/04 §2, in order. The list is the count: a check added here is a row added to the spec's table and a line added below (#13).
iex> Macaw.Component.Conformance.checks()
[:declarations, :kinds, :modes, :delivery, :headings, :names, :keyboard, :colors, :ids,
:drawn, :budget, :order, :contained, :bindings, :context, :selection, :prepared, :held]
@spec checks(atom()) :: {:ok, [atom(), ...]} | {:error, [Macaw.Base.Fault.t(), ...]}
A check set's checks, in order: {:ok, checks}, or {:enum, sets} for a name that is
no check set.
iex> Macaw.Component.Conformance.checks(:audio)
{:error, [{[], {:enum, [:visual]}}]}
A finding as a line a person reads.