From f8d83d18aa46f207a00ccc5114a7df53391bc404 Mon Sep 17 00:00:00 2001 From: JP Richardson Date: Wed, 29 Oct 2014 11:17:05 -0500 Subject: [PATCH] test/output.test: refactored a bit --- test/output.test.js | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/test/output.test.js b/test/output.test.js index ec14b23..9bba5d5 100644 --- a/test/output.test.js +++ b/test/output.test.js @@ -1,22 +1,26 @@ -var testutil = require('testutil') - , fs = require('../') - , path = require('path') - +var fs = require('fs') +var path = require('path') var terst = require('terst') +var testutil = require('testutil') +var fse = require('../') var TEST_DIR = '' -describe('fs-extra', function () { +describe('output', function () { beforeEach(function() { TEST_DIR = testutil.createTestDir('fs-extra') }) + afterEach(function(done) { + fse.remove(TEST_DIR, done) + }) + describe('+ outputFile', function() { describe('> when the file and directory does not exist', function() { it('should create the file', function(done) { var file = path.join(TEST_DIR, Math.random() + 't-ne', Math.random() + '.txt') F (fs.existsSync(file)) - fs.outputFile(file, 'hi jp', function(err) { + fse.outputFile(file, 'hi jp', function(err) { F (err) T (fs.existsSync(file)) EQ (fs.readFileSync(file, 'utf8'), 'hi jp') @@ -28,9 +32,9 @@ describe('fs-extra', function () { describe('> when the file does exist', function() { it('should still modify the file', function(done) { var file = path.join(TEST_DIR, Math.random() + 't-e', Math.random() + '.txt') - fs.mkdirsSync(path.dirname(file)) + fse.mkdirsSync(path.dirname(file)) fs.writeFileSync(file, 'hello world') - fs.outputFile(file, 'hello jp', function(err) { + fse.outputFile(file, 'hello jp', function(err) { if (err) return done(err) EQ (fs.readFileSync(file, 'utf8'), 'hello jp') done() @@ -44,7 +48,7 @@ describe('fs-extra', function () { it('should create the file', function() { var file = path.join(TEST_DIR, Math.random() + 'ts-ne', Math.random() + '.txt') F (fs.existsSync(file)) - fs.outputFileSync(file, 'hello man') + fse.outputFileSync(file, 'hello man') T (fs.existsSync(file)) EQ (fs.readFileSync(file, 'utf8'), 'hello man') }) @@ -53,9 +57,9 @@ describe('fs-extra', function () { describe('> when the file does exist', function() { it('should still modify the file', function() { var file = path.join(TEST_DIR, Math.random() + 'ts-e', Math.random() + '.txt') - fs.mkdirsSync(path.dirname(file)) + fse.mkdirsSync(path.dirname(file)) fs.writeFileSync(file, 'hello world') - fs.outputFileSync(file, 'hello man') + fse.outputFileSync(file, 'hello man') EQ (fs.readFileSync(file, 'utf8'), 'hello man') }) })