feat: throw an Error if delimiter not matched

This commit is contained in:
harttle
2019-02-20 22:40:09 +08:00
parent c13a16fdd6
commit c33d8f6828
5 changed files with 62 additions and 28 deletions
+11 -1
View File
@@ -6,7 +6,7 @@ import HTMLToken from 'src/parser/html-token'
describe('tokenizer', function () {
const tokenizer = new Tokenizer()
describe('parse', function () {
describe('#tokenize()', function () {
it('should handle plain HTML', function () {
const html = '<html><body><p>Lorem Ipsum</p></body></html>'
const tokens = tokenizer.tokenize(html)
@@ -66,5 +66,15 @@ describe('tokenizer', function () {
expect(tokens[0]).instanceOf(OutputToken)
expect(tokens[0].raw).to.equal('{{foo\n|date:\n"%Y-%m-%d"\n}}')
})
it('should throw if tag not closed', function () {
expect(() => {
tokenizer.tokenize('{% assign foo = bar {{foo}}')
}).to.throw(/tag "{% assign foo..." not closed/)
})
it('should throw if output not closed', function () {
expect(() => {
tokenizer.tokenize('{{name}')
}).to.throw(/output "{{name}" not closed/)
})
})
})