test: case for "." path handling

This commit is contained in:
Yang Jun
2024-10-25 21:47:06 +08:00
parent 28b14901d3
commit b173d1a00a
4 changed files with 14 additions and 4 deletions
+10
View File
@@ -52,4 +52,14 @@ describe('#renderFile()', function () {
})
return expect(engine.renderFile('/not/exist.html')).rejects.toThrow(/Failed to lookup "\/not\/exist.html" in "\/boo,\/root\/"/)
})
it('should handle "." as cwd', async () => {
engine = new Liquid({
root: ['.'],
extname: '.html'
})
process.chdir(resolve(__dirname, '../stub/views'))
await expect(engine.renderFile('bar')).resolves.toEqual('BAR')
process.chdir(resolve(__dirname, '../stub/partials'))
await expect(engine.renderFile('bar')).resolves.toEqual('bar')
})
})