1
0
mirror of https://github.com/danog/liquid.git synced 2024-11-27 04:35:14 +01:00
liquid/render/blocks_test.go
Oliver Steele 413b3283bf Coverage
2017-07-19 09:42:01 -04:00

25 lines
597 B
Go

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())
}