1
0
mirror of https://github.com/danog/liquid.git synced 2024-11-26 21:34:44 +01:00
liquid/render/blocks_test.go

25 lines
597 B
Go
Raw Permalink Normal View History

2017-07-19 15:42:01 +02:00
package render
import (
"testing"
"github.com/stretchr/testify/require"
)
func TestBlockSyntax(t *testing.T) {
cfg := NewConfig()
cfg.AddBlock("if").Clause("else")
cfg.AddBlock("case").Clause("else")
cfg.AddBlock("unless")
require.Panics(t, func() { cfg.AddBlock("if") })
g := cfg.grammar
ifBlock, _ := g.findBlockDef("if")
elseBlock, _ := g.findBlockDef("else")
unlessBlock, _ := g.findBlockDef("unless")
require.True(t, elseBlock.CanHaveParent(ifBlock))
require.False(t, elseBlock.CanHaveParent(unlessBlock))
require.Equal(t, []string{"case", "if"}, elseBlock.ParentTags())
}