From 8f46b62a6122fd51eebd6dbfe1fc15ba88faaccb Mon Sep 17 00:00:00 2001 From: NikolaLohinski Date: Sat, 11 May 2024 22:55:07 +0200 Subject: [PATCH] chore(tests): add a test for block control structure multiple reusing of self --- .../control_structure_block_test.go | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/tests/integration/control_structure_block_test.go b/tests/integration/control_structure_block_test.go index 35cb44c..c263b09 100644 --- a/tests/integration/control_structure_block_test.go +++ b/tests/integration/control_structure_block_test.go @@ -65,4 +65,36 @@ var _ = Context("control structure 'block'", func() { AssertPrettyDiff(expected, *returnedResult) }) }) + Context("when reusing the self block multiple times", func() { + BeforeEach(func() { + *loader = loaders.MustNewMemoryLoader(map[string]string{ + *identifier: heredoc.Doc(` + {% block block -%} + reused content + {%- endblock block %} + + some content in between + + {{ self.block() }} + {{ self.block() }} + `), + }) + }) + + It("should return the expected rendered content", func() { + By("not returning any error") + Expect(*returnedErr).To(BeNil()) + By("returning the expected result") + expected := heredoc.Doc(` + reused content + + some content in between + + reused content + reused content + `) + AssertPrettyDiff(expected, *returnedResult) + }) + }) + })