mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-17 05:10:40 -07:00
feature: template file lookup error message
This commit is contained in:
+8
-3
@@ -48,9 +48,14 @@ describe('engine#express()', function() {
|
||||
var file = '/not-exist.html';
|
||||
var ctx = {};
|
||||
engine.express().call(view, file, ctx, function(err) {
|
||||
expect(err.code).to.equal('ENOENT');
|
||||
console.log(err.message);
|
||||
done();
|
||||
try{
|
||||
expect(err.code).to.equal('ENOENT');
|
||||
expect(err.message).to.match(/Failed to lookup/);
|
||||
done();
|
||||
}
|
||||
catch(e){
|
||||
done(e);
|
||||
}
|
||||
});
|
||||
});
|
||||
it('should respect root option when lookup', function(done) {
|
||||
|
||||
+11
-9
@@ -21,7 +21,10 @@ describe('liquid', function() {
|
||||
});
|
||||
mock({
|
||||
'/root/files/foo.html': 'foo',
|
||||
'/root/files/name.html': 'My name is {{name}}.'
|
||||
'/root/files/name.html': 'My name is {{name}}.',
|
||||
'/un-readable.html': mock.file({
|
||||
mode: '0000'
|
||||
})
|
||||
});
|
||||
});
|
||||
afterEach(function() {
|
||||
@@ -99,18 +102,17 @@ describe('liquid', function() {
|
||||
it('should use default extname', function() {
|
||||
return engine.renderFile('files/name', ctx).should.eventually.equal('My name is harttle.');
|
||||
});
|
||||
it('should accept root with no trailing slash', function() {
|
||||
it('should throw with lookup list when file not exist', function() {
|
||||
engine = Liquid({
|
||||
root: '/root',
|
||||
root: ['/boo', '/root/'],
|
||||
extname: '.html'
|
||||
});
|
||||
return expect(engine.renderFile('files/foo.html')).to.eventually.equal('foo');
|
||||
return expect(engine.renderFile('/not/exist.html')).to
|
||||
.be.rejectedWith(/failed to lookup \/not\/exist.html in: \/boo,\/root\//i);
|
||||
});
|
||||
it('should accept dot path', function() {
|
||||
return expect(engine.renderFile('./files/foo.html')).to.eventually.equal('foo');
|
||||
});
|
||||
it('should accept double-dot path', function() {
|
||||
return expect(engine.renderFile('files/foo/../foo.html')).to.eventually.equal('foo');
|
||||
it('should throw when file not readable', function() {
|
||||
return expect(engine.renderFile('/un-readable.html')).to
|
||||
.be.rejectedWith(/EACCES/);
|
||||
});
|
||||
});
|
||||
describe('strict', function() {
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
const chai = require("chai");
|
||||
const expect = chai.expect;
|
||||
|
||||
const fs = require('../../src/util/fs.js');
|
||||
const pathResolve = fs.pathResolve;
|
||||
|
||||
describe('fs', function() {
|
||||
describe('.pathResolve(root, path)', function() {
|
||||
it('should accept root with no trailing slash', function() {
|
||||
expect(pathResolve('/root', 'files/foo.html')).to.equal('/root/files/foo.html');
|
||||
});
|
||||
it('should accept root with trailing slash', function() {
|
||||
expect(pathResolve('/root/', 'files/foo.html')).to.equal('/root/files/foo.html');
|
||||
});
|
||||
it('should accept dot path', function() {
|
||||
expect(pathResolve('/root', './foo.html')).to.equal('/root/foo.html');
|
||||
});
|
||||
it('should accept double-dot path', function() {
|
||||
expect(pathResolve('/root', 'files/../foo.html')).to.equal('/root/foo.html');
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user