node-fs-extra/test/mkdirp/return.test.js
2015-04-12 22:28:27 -05:00

31 lines
978 B
JavaScript

var assert = require('assert')
var path = require('path')
var fse = require('../../')
var testutil = require('testutil')
/* global describe, it */
describe('mkdirp / return value', function () {
it('should', function (done) {
var x = Math.floor(Math.random() * Math.pow(16, 4)).toString(16)
var y = Math.floor(Math.random() * Math.pow(16, 4)).toString(16)
var z = Math.floor(Math.random() * Math.pow(16, 4)).toString(16)
var dir = testutil.createTestDir('fs-extra') + path.sep
var file = dir + [x, y, z].join(path.sep)
// should return the first dir created.
// By this point, it would be profoundly surprising if /tmp didn't
// already exist, since every other test makes things in there.
fse.mkdirp(file, function (err, made) {
assert.ifError(err)
assert.equal(made, dir + x)
fse.mkdirp(file, function (err, made) {
assert.ifError(err)
assert.equal(made, null)
done()
})
})
})
})