test: case for "." path handling

This commit is contained in:
Yang Jun
2024-11-12 23:59:40 +08:00
committed by Jun Yang
parent 28b14901d3
commit 0b195b21eb
4 changed files with 14 additions and 4 deletions
+2 -2
View File
@@ -35,7 +35,7 @@ describe('express()', function () {
it('should respect express views(string)', function (done) {
app.set('views', views)
request(app).get('/include/bar')
.expect('bar')
.expect('BAR')
.expect(200, done)
})
it('should pass error when file not found', function (done) {
@@ -63,7 +63,7 @@ describe('express()', function () {
it('should respect express views (Array) when lookup', function (done) {
app.set('views', [views, partials])
request(app).get('/include/bar')
.expect('bar')
.expect('BAR')
.expect(200, done)
})
})
+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')
})
})
+1 -1
View File
@@ -1,7 +1,7 @@
import { normalize } from '../../../src/liquid-options'
describe('LiquidOptions#root', function () {
describe('#normalize ()', function () {
describe('#normalize()', function () {
it('should normalize string typed root array', function () {
const options = normalize({ root: 'foo' })
expect(options.root).toEqual(['foo'])
+1 -1
View File
@@ -1 +1 @@
bar
BAR