From edc26922f27dabd047202fceafc40ce47c17191d Mon Sep 17 00:00:00 2001 From: JP Richardson Date: Mon, 18 Mar 2013 11:43:56 -0500 Subject: [PATCH] Added new test. --- lib/index.js | 13 ++++++------- test/fs-integration.test.js | 18 ++++++++++++++++++ 2 files changed, 24 insertions(+), 7 deletions(-) create mode 100644 test/fs-integration.test.js diff --git a/lib/index.js b/lib/index.js index ab297eaf..5d86d08a 100644 --- a/lib/index.js +++ b/lib/index.js @@ -3,13 +3,12 @@ var fs = require('fs') , jsonFile = require('jsonfile') , fse = {}; -for (var funcName in fs) { - var func = fs[funcName]; - if (fs.hasOwnProperty(funcName)) { - if (typeof func == 'function') - fse[funcName] = func; - } -} +Object.keys(fs).forEach(function(key) { + var func = fs[key]; + if (typeof func == 'function') + fse[key] = func; +}); + fs = fse; diff --git a/test/fs-integration.test.js b/test/fs-integration.test.js new file mode 100644 index 00000000..15e4000a --- /dev/null +++ b/test/fs-integration.test.js @@ -0,0 +1,18 @@ +var testutil = require('testutil') + , fs = require('../') + , path = require('path') + +var TEST_DIR; + +describe('native fs', function() { + beforeEach(function() { + TEST_DIR = testutil.createTestDir('fs-extra') + }) + + it('should use native fs methods', function() { + var file = path.join(TEST_DIR, 'write.txt') + fs.writeFileSync(file, 'hello') + var data = fs.readFileSync(file, 'utf8') + EQ (data, 'hello') + }) +}) \ No newline at end of file