mirror of
https://github.com/jprichardson/node-fs-extra.git
synced 2026-01-25 16:42:57 +00:00
test/json.test: refactored
This commit is contained in:
parent
903d4018e2
commit
33fc3537db
@ -1,25 +1,27 @@
|
||||
"use strict"
|
||||
|
||||
var fs = require('fs')
|
||||
var path = require('path')
|
||||
var testutil = require('testutil')
|
||||
, fs = require('../lib')
|
||||
, path = require('path')
|
||||
|
||||
var terst = require('terst')
|
||||
var fse = require('../')
|
||||
|
||||
var TEST_DIR = null
|
||||
|
||||
describe('fs-extra', function() {
|
||||
describe('json', function() {
|
||||
beforeEach(function() {
|
||||
TEST_DIR = testutil.createTestDir('fs-extra')
|
||||
})
|
||||
|
||||
afterEach(function(done) {
|
||||
fse.remove(TEST_DIR, done)
|
||||
})
|
||||
|
||||
describe('+ outputJsonSync(file, data)', function() {
|
||||
it('should write the file regardless of whether the directory exists or not', function() {
|
||||
var file = path.join(TEST_DIR, 'this-dir', 'does-not', 'exist', 'file.json')
|
||||
F (fs.existsSync(file))
|
||||
|
||||
var data = {name: 'JP'}
|
||||
fs.outputJsonSync(file, data)
|
||||
fse.outputJsonSync(file, data)
|
||||
|
||||
T (fs.existsSync(file))
|
||||
var newData = JSON.parse(fs.readFileSync(file, 'utf8'))
|
||||
@ -34,7 +36,7 @@ describe('fs-extra', function() {
|
||||
F (fs.existsSync(file))
|
||||
|
||||
var data = {name: 'JP'}
|
||||
fs.outputJson(file, data, function(err) {
|
||||
fse.outputJson(file, data, function(err) {
|
||||
if (err) return done(err)
|
||||
|
||||
T (fs.existsSync(file))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user