Support FixedIndent, add tests
This commit is contained in:
@@ -0,0 +1,92 @@
|
||||
package tests
|
||||
|
||||
import (
|
||||
"git.virtual.blue/tomgracey/template-nest-go"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestRenderSimplePageWithFixedIndent(t *testing.T) {
|
||||
nest, err := templatenest.New(templatenest.Option{
|
||||
TemplateDir: "templates",
|
||||
FixedIndent: true,
|
||||
})
|
||||
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": "02-simple-component-multi-line",
|
||||
},
|
||||
}
|
||||
outputPage := templatenest.Hash{"TEMPLATE": "output/07-simple-page-fixed-indent"}
|
||||
|
||||
render := nest.MustRender(page)
|
||||
outputRender := nest.MustRender(outputPage)
|
||||
|
||||
assert.Equal(t, outputRender, render, "Rendered output does not match expected output")
|
||||
}
|
||||
|
||||
func TestRenderComplexPageWithFixedIndent(t *testing.T) {
|
||||
nest, err := templatenest.New(templatenest.Option{
|
||||
TemplateDir: "templates",
|
||||
FixedIndent: true,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to initialize TemplateNest: %+v", err)
|
||||
}
|
||||
|
||||
page := templatenest.Hash{
|
||||
"TEMPLATE": "10-complex-page",
|
||||
"title": "Complex Page",
|
||||
"pre_body": templatenest.Hash{
|
||||
"TEMPLATE": "18-styles",
|
||||
},
|
||||
"navigation": templatenest.Hash{
|
||||
"TEMPLATE": "11-navigation",
|
||||
"banner": templatenest.Hash{
|
||||
"TEMPLATE": "12-navigation-banner",
|
||||
},
|
||||
"items": []templatenest.Hash{
|
||||
templatenest.Hash{"TEMPLATE": "13-navigation-item-00-services"},
|
||||
templatenest.Hash{"TEMPLATE": "13-navigation-item-01-resources"},
|
||||
},
|
||||
},
|
||||
"hero_section": templatenest.Hash{
|
||||
"TEMPLATE": "14-hero-section",
|
||||
},
|
||||
"main_content": []templatenest.Hash{
|
||||
templatenest.Hash{"TEMPLATE": "15-isdc-card"},
|
||||
templatenest.Hash{
|
||||
"TEMPLATE": "16-vb-brand-cards",
|
||||
"cards": []templatenest.Hash{
|
||||
templatenest.Hash{
|
||||
"TEMPLATE": "17-vb-brand-card-00",
|
||||
"parent_classes": "p-card brand-card col-4",
|
||||
},
|
||||
templatenest.Hash{
|
||||
"TEMPLATE": "17-vb-brand-card-01",
|
||||
"parent_classes": "p-card brand-card col-4",
|
||||
},
|
||||
templatenest.Hash{
|
||||
"TEMPLATE": "17-vb-brand-card-02",
|
||||
"parent_classes": "p-card brand-card col-4",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"post_footer": templatenest.Hash{
|
||||
"TEMPLATE": "19-scripts",
|
||||
},
|
||||
}
|
||||
|
||||
outputPage := templatenest.Hash{"TEMPLATE": "output/08-complex-page-fixed-indent"}
|
||||
|
||||
render := nest.MustRender(page)
|
||||
outputRender := nest.MustRender(outputPage)
|
||||
|
||||
assert.Equal(t, outputRender, render, "Rendered output does not match expected output")
|
||||
}
|
||||
Reference in New Issue
Block a user