mirror of
https://github.com/danog/liquid.git
synced 2024-11-27 01:44:39 +01:00
Chunk scanner test cases
This commit is contained in:
parent
babfc3e527
commit
fc6d96ed40
45
chunks/scanner_test.go
Normal file
45
chunks/scanner_test.go
Normal file
@ -0,0 +1,45 @@
|
||||
package chunks
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
var scannerTests = []struct{ in, expected string }{
|
||||
{"{{12}}", "12"},
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
Loading…
Reference in New Issue
Block a user