mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-16 21:00:40 -07:00
chore(TypeScript): fix linting and generate .d.ts
This commit is contained in:
@@ -1,14 +1,15 @@
|
||||
import { expect } from 'chai'
|
||||
import { parse } from 'src/parser/tokenizer'
|
||||
import Tokenizer from 'src/parser/tokenizer'
|
||||
import TagToken from 'src/parser/tag-token'
|
||||
import OutputToken from 'src/parser/output-token'
|
||||
import HTMLToken from 'src/parser/html-token'
|
||||
|
||||
describe('tokenizer', function () {
|
||||
const tokenizer = new Tokenizer()
|
||||
describe('parse', function () {
|
||||
it('should handle plain HTML', function () {
|
||||
const html = '<html><body><p>Lorem Ipsum</p></body></html>'
|
||||
const tokens = parse(html)
|
||||
const tokens = tokenizer.tokenize(html)
|
||||
|
||||
expect(tokens.length).to.equal(1)
|
||||
expect(tokens[0].value).to.equal(html)
|
||||
@@ -16,7 +17,7 @@ describe('tokenizer', function () {
|
||||
})
|
||||
it('should handle tag syntax', function () {
|
||||
const html = '<p>{% for p in a[1]%}</p>'
|
||||
const tokens = parse(html)
|
||||
const tokens = tokenizer.tokenize(html)
|
||||
|
||||
expect(tokens.length).to.equal(3)
|
||||
expect(tokens[1]).instanceOf(TagToken)
|
||||
@@ -24,7 +25,7 @@ describe('tokenizer', function () {
|
||||
})
|
||||
it('should handle value syntax', function () {
|
||||
const html = '<p>{{foo | date: "%Y-%m-%d"}}</p>'
|
||||
const tokens = parse(html)
|
||||
const tokens = tokenizer.tokenize(html)
|
||||
|
||||
expect(tokens.length).to.equal(3)
|
||||
expect(tokens[1]).instanceOf(OutputToken)
|
||||
@@ -32,7 +33,7 @@ describe('tokenizer', function () {
|
||||
})
|
||||
it('should handle consecutive value and tags', function () {
|
||||
const html = '{{foo}}{{bar}}{%foo%}{%bar%}'
|
||||
const tokens = parse(html)
|
||||
const tokens = tokenizer.tokenize(html)
|
||||
|
||||
expect(tokens.length).to.equal(4)
|
||||
expect(tokens[0]).instanceOf(OutputToken)
|
||||
@@ -43,7 +44,7 @@ describe('tokenizer', function () {
|
||||
})
|
||||
it('should keep white spaces and newlines', function () {
|
||||
const html = '{%foo%}\n{%bar %} \n {%alice%}'
|
||||
const tokens = parse(html)
|
||||
const tokens = tokenizer.tokenize(html)
|
||||
expect(tokens.length).to.equal(5)
|
||||
expect(tokens[1]).instanceOf(HTMLToken)
|
||||
expect(tokens[1].raw).to.equal('\n')
|
||||
@@ -52,7 +53,7 @@ describe('tokenizer', function () {
|
||||
})
|
||||
it('should handle multiple lines tag', function () {
|
||||
const html = '{%foo\na:a\nb:1.23\n%}'
|
||||
const tokens = parse(html)
|
||||
const tokens = tokenizer.tokenize(html)
|
||||
expect(tokens.length).to.equal(1)
|
||||
expect(tokens[0]).instanceOf(TagToken)
|
||||
expect(tokens[0].args).to.equal('a:a\nb:1.23')
|
||||
@@ -60,7 +61,7 @@ describe('tokenizer', function () {
|
||||
})
|
||||
it('should handle multiple lines value', function () {
|
||||
const html = '{{foo\n|date:\n"%Y-%m-%d"\n}}'
|
||||
const tokens = parse(html)
|
||||
const tokens = tokenizer.tokenize(html)
|
||||
expect(tokens.length).to.equal(1)
|
||||
expect(tokens[0]).instanceOf(OutputToken)
|
||||
expect(tokens[0].raw).to.equal('{{foo\n|date:\n"%Y-%m-%d"\n}}')
|
||||
|
||||
Reference in New Issue
Block a user