mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-15 04:10:40 -07:00
fix: unit test on Node.js 6
This commit is contained in:
+3
-3
@@ -1,4 +1,4 @@
|
||||
import { isString } from 'src/util/underscore'
|
||||
import { isString, forOwn } from 'src/util/underscore'
|
||||
import fs from 'src/fs'
|
||||
|
||||
type fileDescriptor = { mode: string, content: string }
|
||||
@@ -8,11 +8,11 @@ const readFile = fs.readFile
|
||||
const exists = fs.exists
|
||||
|
||||
export function mock (options: { [path: string]: (string | fileDescriptor) }) {
|
||||
for (const [key, val] of Object.entries(options)) {
|
||||
forOwn(options, (val, key) => {
|
||||
files[key] = isString(val)
|
||||
? { mode: '33188', content: val as string }
|
||||
: val as fileDescriptor
|
||||
}
|
||||
})
|
||||
fs.readFile = async function (path) {
|
||||
console.log('mock fs read called', path)
|
||||
const file = files[path]
|
||||
|
||||
Reference in New Issue
Block a user