package tests import ( "git.virtual.blue/tomgracey/template-nest-go" "github.com/stretchr/testify/assert" "testing" ) func TestRenderWithShowLabels(t *testing.T) { nest, err := templatenest.New(templatenest.Option{ TemplateDir: "templates", ShowLabels: true, }) if err != nil { t.Fatalf("Failed to initialize TemplateNest: %+v", err) } nestNoLabels, err := templatenest.New(templatenest.Option{TemplateDir: "templates"}) if err != nil { t.Fatalf("Failed to initialize TemplateNest: %+v", err) } page := templatenest.Hash{ "TEMPLATE": "00-simple-page", "variable": "Simple Variable", "simple_component": templatenest.Hash{ "TEMPLATE": "01-simple-component", "variable": "Simple Variable in Simple Component", }, } outputPage := templatenest.Hash{"TEMPLATE": "output/04-simple-page-with-labels"} render := nest.MustRender(page) outputRender := nestNoLabels.MustRender(outputPage) assert.Equal(t, outputRender, render, "Rendered output does not match expected output") } func TestRenderWithShowLabelsAltDelimiters(t *testing.T) { nest, err := templatenest.New(templatenest.Option{ TemplateDir: "templates", ShowLabels: true, CommentDelimiters: [2]string{""}, }) if err != nil { t.Fatalf("Failed to initialize TemplateNest: %+v", err) } nestNoLabels, err := templatenest.New(templatenest.Option{TemplateDir: "templates"}) if err != nil { t.Fatalf("Failed to initialize TemplateNest: %+v", err) } page := templatenest.Hash{ "TEMPLATE": "00-simple-page", "variable": "Simple Variable", "simple_component": templatenest.Hash{ "TEMPLATE": "01-simple-component", "variable": "Simple Variable in Simple Component", }, } outputPage := templatenest.Hash{"TEMPLATE": "output/05-simple-page-with-labels-alt-delims"} render := nest.MustRender(page) outputRender := nestNoLabels.MustRender(outputPage) assert.Equal(t, outputRender, render, "Rendered output does not match expected output") }