1
0
mirror of https://github.com/danog/liquid.git synced 2024-11-27 12:44:53 +01:00
liquid/chunks/scanner_test.go
Oliver Steele c4bd99bc2c Lint
2017-06-27 13:36:38 -04:00

42 lines
1.1 KiB
Go

package chunks
import (
"testing"
"github.com/stretchr/testify/require"
)
func TestScanner(t *testing.T) {
tokens := Scan("12", "")
require.NotNil(t, tokens)
require.Len(t, tokens, 1)
require.Equal(t, TextChunkType, tokens[0].Type)
require.Equal(t, "12", tokens[0].Source)
tokens = Scan("{{obj}}", "")
require.NotNil(t, tokens)
require.Len(t, tokens, 1)
require.Equal(t, ObjChunkType, tokens[0].Type)
require.Equal(t, "obj", tokens[0].Args)
tokens = Scan("{{ obj }}", "")
require.NotNil(t, tokens)
require.Len(t, tokens, 1)
require.Equal(t, ObjChunkType, tokens[0].Type)
require.Equal(t, "obj", tokens[0].Args)
tokens = Scan("{%tag args%}", "")
require.NotNil(t, tokens)
require.Len(t, tokens, 1)
require.Equal(t, TagChunkType, tokens[0].Type)
require.Equal(t, "tag", tokens[0].Tag)
require.Equal(t, "args", tokens[0].Args)
tokens = Scan("{% tag args %}", "")
require.NotNil(t, tokens)
require.Len(t, tokens, 1)
require.Equal(t, TagChunkType, tokens[0].Type)
require.Equal(t, "tag", tokens[0].Tag)
require.Equal(t, "args", tokens[0].Args)
}