use native path

This commit is contained in:
harttle
2016-11-06 17:20:03 +08:00
parent a82e50e1ab
commit fd2df81f9c
6 changed files with 16 additions and 40 deletions
+11
View File
@@ -96,6 +96,17 @@ describe('liquid', function() {
return expect(engine.renderFile('files/foo.html'))
.to.eventually.equal('foo');
});
it('should default root to cwd', function(){
var files = {};
files[process.cwd() + '/foo.html'] = 'FOO';
mock(files);
engine = Liquid({
extname: '.html'
});
return expect(engine.renderFile('foo.html'))
.to.eventually.equal('FOO');
});
it('should render file with context', function() {
return engine.renderFile('/root/files/name.html', ctx).should.eventually.equal('My name is harttle.');
});
-22
View File
@@ -1,22 +0,0 @@
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');
});
});
});