From cbebb00ef135bc095ea4064816d90c47c1fbea83 Mon Sep 17 00:00:00 2001 From: harttle Date: Tue, 19 Feb 2019 23:25:08 +0800 Subject: [PATCH] fix: unit test on Node.js 6 --- test/stub/mockfs.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/stub/mockfs.ts b/test/stub/mockfs.ts index 4668bbd60..aa600309f 100644 --- a/test/stub/mockfs.ts +++ b/test/stub/mockfs.ts @@ -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]