mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-15 12:20:40 -07:00
Changes including: - will not call fs.resolve when normalizing `fs` - removed hardcoded `/` - mandatory `fs.dirname` for relative reference - mandatory `fs.sep`, defaults to '/'
27 lines
1.2 KiB
TypeScript
27 lines
1.2 KiB
TypeScript
import { expect, use } from 'chai'
|
|
import * as fs from '../../../src/fs/node'
|
|
import * as chaiAsPromised from 'chai-as-promised'
|
|
import { Loader } from '../../../src/fs/loader'
|
|
|
|
use(chaiAsPromised)
|
|
|
|
describe('fs/loader', function () {
|
|
describe('.candidates()', function () {
|
|
it('should resolve relatively', async function () {
|
|
const loader = new Loader({ relativeReference: true, fs, extname: '' } as any)
|
|
const candidates = [...loader.candidates('./foo/bar', ['/root', '/root/foo'], '/root/current', true)]
|
|
expect(candidates).to.contain('/root/foo/bar')
|
|
})
|
|
it('should not include out of root candidates', async function () {
|
|
const loader = new Loader({ relativeReference: true, fs, extname: '' } as any)
|
|
const candidates = [...loader.candidates('../foo/bar', ['/root'], '/root/current', true)]
|
|
expect(candidates).to.have.lengthOf(0)
|
|
})
|
|
it('should treat root as a terminated path', async function () {
|
|
const loader = new Loader({ relativeReference: true, fs, extname: '' } as any)
|
|
const candidates = [...loader.candidates('../root-dir/bar', ['/root'], '/root/current', true)]
|
|
expect(candidates).to.have.lengthOf(0)
|
|
})
|
|
})
|
|
})
|