refactor: import rollup

This commit is contained in:
harttle
2018-08-20 23:58:41 +08:00
parent 4ece4e208f
commit bc9d8f92af
82 changed files with 8589 additions and 3963 deletions
+14 -14
View File
@@ -5,8 +5,8 @@ const expect = chai.expect
describe('tokenizer', function () {
describe('parse', function () {
it('should handle plain HTML', function () {
let html = '<html><body><p>Lorem Ipsum</p></body></html>'
let tokens = parse(html)
const html = '<html><body><p>Lorem Ipsum</p></body></html>'
const tokens = parse(html)
expect(tokens.length).to.equal(1)
expect(tokens[0].value).to.equal(html)
@@ -18,24 +18,24 @@ describe('tokenizer', function () {
}).to.throw('illegal input')
})
it('should handle tag syntax', function () {
let html = '<p>{% for p in a[1]%}</p>'
let tokens = parse(html)
const html = '<p>{% for p in a[1]%}</p>'
const tokens = parse(html)
expect(tokens.length).to.equal(3)
expect(tokens[1].type).to.equal('tag')
expect(tokens[1].value).to.equal('for p in a[1]')
})
it('should handle value syntax', function () {
let html = '<p>{{foo | date: "%Y-%m-%d"}}</p>'
let tokens = parse(html)
const html = '<p>{{foo | date: "%Y-%m-%d"}}</p>'
const tokens = parse(html)
expect(tokens.length).to.equal(3)
expect(tokens[1].type).to.equal('value')
expect(tokens[1].value).to.equal('foo | date: "%Y-%m-%d"')
})
it('should handle consecutive value and tags', function () {
let html = '{{foo}}{{bar}}{%foo%}{%bar%}'
let tokens = parse(html)
const html = '{{foo}}{{bar}}{%foo%}{%bar%}'
const tokens = parse(html)
expect(tokens.length).to.equal(4)
expect(tokens[0].type).to.equal('value')
@@ -45,8 +45,8 @@ describe('tokenizer', function () {
expect(tokens[2].value).to.equal('foo')
})
it('should keep white spaces and newlines', function () {
let html = '{%foo%}\n{%bar %} \n {%alice%}'
let tokens = parse(html)
const html = '{%foo%}\n{%bar %} \n {%alice%}'
const tokens = parse(html)
expect(tokens.length).to.equal(5)
expect(tokens[1].type).to.equal('html')
expect(tokens[1].raw).to.equal('\n')
@@ -54,16 +54,16 @@ describe('tokenizer', function () {
expect(tokens[3].raw).to.equal(' \n ')
})
it('should handle multiple lines tag', function () {
let html = '{%foo\na:a\nb:1.23\n%}'
let tokens = parse(html)
const html = '{%foo\na:a\nb:1.23\n%}'
const tokens = parse(html)
expect(tokens.length).to.equal(1)
expect(tokens[0].type).to.equal('tag')
expect(tokens[0].args).to.equal('a:a\nb:1.23')
expect(tokens[0].raw).to.equal('{%foo\na:a\nb:1.23\n%}')
})
it('should handle multiple lines value', function () {
let html = '{{foo\n|date:\n"%Y-%m-%d"\n}}'
let tokens = parse(html)
const html = '{{foo\n|date:\n"%Y-%m-%d"\n}}'
const tokens = parse(html)
expect(tokens.length).to.equal(1)
expect(tokens[0].type).to.equal('value')
expect(tokens[0].raw).to.equal('{{foo\n|date:\n"%Y-%m-%d"\n}}')