/
return.test.js
41 lines (33 loc) · 1.15 KB
/
return.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
'use strict'
const os = require('os')
const fse = require('../../')
const path = require('path')
const assert = require('assert')
/* global afterEach, beforeEach, describe, it */
describe('mkdirp / return value', () => {
let TEST_DIR
beforeEach(done => {
TEST_DIR = path.join(os.tmpdir(), 'fs-extra', 'mkdirp-return')
fse.emptyDir(TEST_DIR, done)
})
afterEach(done => fse.remove(TEST_DIR, done))
it('should', done => {
const x = Math.floor(Math.random() * Math.pow(16, 4)).toString(16)
const y = Math.floor(Math.random() * Math.pow(16, 4)).toString(16)
const z = Math.floor(Math.random() * Math.pow(16, 4)).toString(16)
const dir = TEST_DIR + path.sep
const 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, (err, made) => {
assert.ifError(err)
assert.strictEqual(made, dir + x)
fse.mkdirp(file, (err, made) => {
assert.ifError(err)
assert.strictEqual(made, null)
done()
})
})
})
})