feat: locale support for date filter, #567 (#723)

This commit is contained in:
Jun Yang
2024-07-22 00:39:44 +08:00
committed by GitHub
parent 542a75fd44
commit e4aeb023fd
29 changed files with 511 additions and 318 deletions
+1 -1
View File
@@ -27,7 +27,7 @@ export class Loader {
const rRelativePath = new RegExp(['.' + sep, '..' + sep, './', '../'].map(prefix => escapeRegex(prefix)).join('|'))
this.shouldLoadRelative = (referencedFile: string) => rRelativePath.test(referencedFile)
} else {
this.shouldLoadRelative = (referencedFile: string) => false
this.shouldLoadRelative = (_referencedFile: string) => false
}
this.contains = this.options.fs.contains || (() => true)
}
+32 -19
View File
@@ -2,25 +2,38 @@ import { MapFS } from './map-fs'
describe('MapFS', () => {
const fs = new MapFS({})
it('should resolve relative file paths', () => {
expect(fs.resolve('foo/bar', 'coo', '')).toEqual('foo/bar/coo')
describe('#resolve()', () => {
it('should resolve relative file paths', () => {
expect(fs.resolve('foo/bar', 'coo', '')).toEqual('foo/bar/coo')
})
it('should resolve to parent', () => {
expect(fs.resolve('foo/bar', '../coo', '')).toEqual('foo/coo')
})
it('should resolve to root', () => {
expect(fs.resolve('foo/bar', '../../coo', '')).toEqual('coo')
})
it('should resolve exceeding root', () => {
expect(fs.resolve('foo/bar', '../../../coo', '')).toEqual('coo')
})
it('should resolve from absolute path', () => {
expect(fs.resolve('/foo/bar', '../../coo', '')).toEqual('/coo')
})
it('should resolve exceeding root from absolute path', () => {
expect(fs.resolve('/foo/bar', '../../../coo', '')).toEqual('/coo')
})
it('should resolve from invalid path', () => {
expect(fs.resolve('foo//bar', '../coo', '')).toEqual('foo/coo')
})
it('should resolve current path', () => {
expect(fs.resolve('foo/bar', '.././coo', '')).toEqual('foo/coo')
})
it('should resolve invalid path', () => {
expect(fs.resolve('foo/bar', '..//coo', '')).toEqual('foo/coo')
})
})
it('should resolve to parent', () => {
expect(fs.resolve('foo/bar', '../coo', '')).toEqual('foo/coo')
})
it('should resolve to root', () => {
expect(fs.resolve('foo/bar', '../../coo', '')).toEqual('coo')
})
it('should resolve exceeding root', () => {
expect(fs.resolve('foo/bar', '../../../coo', '')).toEqual('coo')
})
it('should resolve from absolute path', () => {
expect(fs.resolve('/foo/bar', '../../coo', '')).toEqual('/coo')
})
it('should resolve exceeding root from absolute path', () => {
expect(fs.resolve('/foo/bar', '../../../coo', '')).toEqual('/coo')
})
it('should resolve from invalid path', () => {
expect(fs.resolve('foo//bar', '../coo', '')).toEqual('foo/coo')
describe('#.readFileSync()', () => {
it('should throw if not exist', () => {
expect(() => fs.readFileSync('foo/bar')).toThrow('NOENT: foo/bar')
})
})
})