Skip to content

Commit

Permalink
fix: unit test on Node.js 6
Browse files Browse the repository at this point in the history
  • Loading branch information
harttle committed Feb 19, 2019
1 parent 64a9eb7 commit cbebb00
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions test/stub/mockfs.ts
Original file line number Diff line number Diff line change
@@ -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 }
Expand All @@ -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]
Expand Down

0 comments on commit cbebb00

Please sign in to comment.