content`, got) +} + +func TestAX7_Layout_Render_Bad(t *core.T) { + var l *Layout + got := l.Render(NewContext()) + core.AssertEqual(t, "", got) +} + +func TestAX7_Layout_Render_Ugly(t *core.T) { + l := NewLayout("XC").C(Text("content")) + got := l.Render(nil) + core.AssertContains(t, got, "content") +} + +func TestAX7_Layout_VariantError_Good(t *core.T) { + l := NewLayout("C") + err := l.VariantError() + core.AssertNil(t, err) +} + +func TestAX7_Layout_VariantError_Bad(t *core.T) { + var l *Layout + err := l.VariantError() + core.AssertNil(t, err) +} + +func TestAX7_Layout_VariantError_Ugly(t *core.T) { + l := NewLayout("???") + err := l.VariantError() + core.AssertNil(t, err) +} + +func TestAX7_NewContext_Good(t *core.T) { + ctx := NewContext("cy") + core.AssertEqual(t, "cy", ctx.Locale) + core.AssertEqual(t, ctx.Data, ctx.Metadata) +} + +func TestAX7_NewContext_Bad(t *core.T) { + ctx := NewContext() + got := ctx.Locale + core.AssertEqual(t, "", got) +} + +func TestAX7_NewContext_Ugly(t *core.T) { + ctx := NewContext("") + got := ctx.Metadata + core.AssertNotNil(t, got) +} + +func TestAX7_NewContextWithService_Good(t *core.T) { + tr := &ax7Translator{} + ctx := NewContextWithService(tr, "cy") + core.AssertEqual(t, "cy", ctx.Locale) +} + +func TestAX7_NewContextWithService_Bad(t *core.T) { + ctx := NewContextWithService(nil, "cy") + got := ctx.Locale + core.AssertEqual(t, "cy", got) +} + +func TestAX7_NewContextWithService_Ugly(t *core.T) { + tr := &ax7Translator{available: []string{"en"}} + NewContextWithService(tr, "en-GB") + core.AssertEqual(t, "en", tr.lang) +} + +func TestAX7_NewLayout_Good(t *core.T) { + l := NewLayout("C") + core.AssertNotNil(t, l) + core.AssertEqual(t, "", l.Render(NewContext())) +} + +func TestAX7_NewLayout_Bad(t *core.T) { + l := NewLayout("") + got := l.Render(NewContext()) + core.AssertEqual(t, "", got) +} + +func TestAX7_NewLayout_Ugly(t *core.T) { + l := NewLayout("XC").C(Text("content")) + got := l.Render(NewContext()) + core.AssertContains(t, got, "content") +} + +func TestAX7_NewResponsive_Good(t *core.T) { + r := NewResponsive() + core.AssertNotNil(t, r) + core.AssertEqual(t, "", r.Render(NewContext())) +} + +func TestAX7_NewResponsive_Bad(t *core.T) { + r := NewResponsive() + got := len(r.variants) + core.AssertEqual(t, 0, got) +} + +func TestAX7_NewResponsive_Ugly(t *core.T) { + r := NewResponsive().Add("", NewLayout("C").C(Text("content"))) + got := r.Render(NewContext()) + core.AssertContains(t, got, `data-variant=""`) +} + +func TestAX7_Node_Render_Good(t *core.T) { + var node Node = Text("node") + got := node.Render(NewContext()) + core.AssertEqual(t, "node", got) +} + +func TestAX7_Node_Render_Bad(t *core.T) { + var node Node = (*rawNode)(nil) + got := node.Render(NewContext()) + core.AssertEqual(t, "", got) +} + +func TestAX7_Node_Render_Ugly(t *core.T) { + var node Node = emptyNode{} + got := node.Render(NewContext()) + core.AssertEqual(t, "", got) +} + +func TestAX7_ParseBlockID_Good(t *core.T) { + got := ParseBlockID("C.0.H.1") + want := []byte{'C', 'H'} + core.AssertEqual(t, want, got) +} + +func TestAX7_ParseBlockID_Bad(t *core.T) { + got := ParseBlockID("C-0.H") + want := []byte(nil) + core.AssertEqual(t, want, got) +} + +func TestAX7_ParseBlockID_Ugly(t *core.T) { + got := ParseBlockID("H-0-C-0") + want := []byte{'H', 'C'} + core.AssertEqual(t, want, got) +} + +func TestAX7_Raw_Good(t *core.T) { + node := Raw("trusted") + got := node.Render(NewContext()) + core.AssertEqual(t, "trusted", got) +} + +func TestAX7_Raw_Bad(t *core.T) { + node := Raw("") + got := node.Render(NewContext()) + core.AssertEqual(t, "", got) +} + +func TestAX7_Raw_Ugly(t *core.T) { + node := Raw("") + got := node.Render(NewContext()) + core.AssertContains(t, got, "") + got := RenderToString(node) + core.AssertEqual(t, "", got) +}