err.file for #renderFile()

This commit is contained in:
harttle
2016-06-24 12:25:55 +08:00
parent aebf9812cb
commit 88b2dc3795
3 changed files with 23 additions and 3 deletions
+14
View File
@@ -1,6 +1,7 @@
var chai = require("chai");
var expect = chai.expect;
var engine = require('..')(), ctx;
const mock = require('mock-fs');
function test(func, cb){
try{
@@ -34,6 +35,19 @@ describe('error', function() {
});
});
it('should throw correct error info for files', function() {
mock({
"/foo.html": '<html>\n<head>\n\n{% raw %}\n\n'
});
test(function(){
engine.renderFile('/foo.html', {});
}, function(err){
expect(err.input).to.equal('{% raw %}');
expect(err.line).to.equal(4);
expect(err.file).to.equal('/foo.html');
});
});
it('should throw ParseError when filter not exist', function() {
test(function(){
engine.parseAndRender('{{ a | xz }}', {});