test: verify responsive variant path isolation

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Claude 2026-02-17 00:10:33 +00:00
parent 8ac512362a
commit a06e9716c5
No known key found for this signature in database
GPG key ID: AF404715446AEB41

View file

@ -54,6 +54,36 @@ func TestResponsive_VariantOrder(t *testing.T) {
}
}
func TestResponsive_NestedPaths(t *testing.T) {
ctx := NewContext()
inner := NewLayout("HCF").H(Raw("ih")).C(Raw("ic")).F(Raw("if"))
r := NewResponsive().
Variant("desktop", NewLayout("HLCRF").C(inner))
got := r.Render(ctx)
if !strings.Contains(got, `data-block="C-0-H-0"`) {
t.Errorf("nested layout in responsive variant missing C-0-H-0 in:\n%s", got)
}
if !strings.Contains(got, `data-block="C-0-C-0"`) {
t.Errorf("nested layout in responsive variant missing C-0-C-0 in:\n%s", got)
}
}
func TestResponsive_VariantsIndependent(t *testing.T) {
ctx := NewContext()
r := NewResponsive().
Variant("a", NewLayout("HLCRF").C(Raw("content-a"))).
Variant("b", NewLayout("HCF").C(Raw("content-b")))
got := r.Render(ctx)
count := strings.Count(got, `data-block="C-0"`)
if count != 2 {
t.Errorf("expected 2 independent C-0 blocks, got %d in:\n%s", count, got)
}
}
func TestResponsive_ImplementsNode(t *testing.T) {
var _ Node = NewResponsive()
}