From 41826554cd144133a6abe35740d13e0f8e9153eb Mon Sep 17 00:00:00 2001 From: JPeer264 Date: Wed, 22 Feb 2017 13:57:21 +0100 Subject: [PATCH] Refactor test output --- lib/output/__tests__/output.test.js | 54 ++++++++++++++--------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/lib/output/__tests__/output.test.js b/lib/output/__tests__/output.test.js index e1a857bb..59ff05fe 100644 --- a/lib/output/__tests__/output.test.js +++ b/lib/output/__tests__/output.test.js @@ -1,29 +1,29 @@ -var assert = require('assert') -var fs = require('fs') -var path = require('path') -var os = require('os') -var fse = require(process.cwd()) +'use strict' + +const fs = require('fs') +const os = require('os') +const fse = require(process.cwd()) +const path = require('path') +const assert = require('assert') /* global afterEach, beforeEach, describe, it */ -describe('output', function () { - var TEST_DIR +describe('output', () => { + let TEST_DIR - beforeEach(function (done) { + beforeEach(done => { TEST_DIR = path.join(os.tmpdir(), 'fs-extra', 'output') fse.emptyDir(TEST_DIR, done) }) - afterEach(function (done) { - fse.remove(TEST_DIR, done) - }) + afterEach(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') + describe('+ outputFile', () => { + describe('> when the file and directory does not exist', () => { + it('should create the file', done => { + const file = path.join(TEST_DIR, Math.random() + 't-ne', Math.random() + '.txt') assert(!fs.existsSync(file)) - fse.outputFile(file, 'hi jp', function (err) { + fse.outputFile(file, 'hi jp', err => { assert.ifError(err) assert(fs.existsSync(file)) assert.equal(fs.readFileSync(file, 'utf8'), 'hi jp') @@ -32,12 +32,12 @@ describe('output', 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') + describe('> when the file does exist', () => { + it('should still modify the file', done => { + const file = path.join(TEST_DIR, Math.random() + 't-e', Math.random() + '.txt') fse.mkdirsSync(path.dirname(file)) fs.writeFileSync(file, 'hello world') - fse.outputFile(file, 'hello jp', function (err) { + fse.outputFile(file, 'hello jp', err => { if (err) return done(err) assert.equal(fs.readFileSync(file, 'utf8'), 'hello jp') done() @@ -46,10 +46,10 @@ describe('output', function () { }) }) - describe('+ outputFileSync', function () { - describe('> when the file and directory does not exist', function () { - it('should create the file', function () { - var file = path.join(TEST_DIR, Math.random() + 'ts-ne', Math.random() + '.txt') + describe('+ outputFileSync', () => { + describe('> when the file and directory does not exist', () => { + it('should create the file', () => { + const file = path.join(TEST_DIR, Math.random() + 'ts-ne', Math.random() + '.txt') assert(!fs.existsSync(file)) fse.outputFileSync(file, 'hello man') assert(fs.existsSync(file)) @@ -57,9 +57,9 @@ describe('output', 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') + describe('> when the file does exist', () => { + it('should still modify the file', () => { + const file = path.join(TEST_DIR, Math.random() + 'ts-e', Math.random() + '.txt') fse.mkdirsSync(path.dirname(file)) fs.writeFileSync(file, 'hello world') fse.outputFileSync(file, 'hello man')