Skip to content

Commit

Permalink
test: case for "." path handling
Browse files Browse the repository at this point in the history
  • Loading branch information
harttle committed Nov 12, 2024
1 parent 28b1490 commit 0b195b2
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
4 changes: 2 additions & 2 deletions test/e2e/express.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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 changes: 10 additions & 0 deletions test/e2e/render-file.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')
})
})
2 changes: 1 addition & 1 deletion test/integration/liquid/root.spec.ts
Original file line number Diff line number Diff line change
@@ -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'])
Expand Down
2 changes: 1 addition & 1 deletion test/stub/views/bar.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
bar
BAR

0 comments on commit 0b195b2

Please sign in to comment.