arnaucube
arnaucube/socketioMEANseedPublic Self-hosted repository
socketioMEANseed/www/node_modules/mkdirp/test/return.js
www/node_modules/mkdirp/test/return.jsRaw
 1var mkdirp = require('../');
 2var path = require('path');
 3var fs = require('fs');
 4var test = require('tap').test;
 5
 6test('return value', function (t) {
 7    t.plan(4);
 8    var x = Math.floor(Math.random() * Math.pow(16,4)).toString(16);
 9    var y = Math.floor(Math.random() * Math.pow(16,4)).toString(16);
10    var z = Math.floor(Math.random() * Math.pow(16,4)).toString(16);
11
12    var file = '/tmp/' + [x,y,z].join('/');
13
14    // should return the first dir created.
15    // By this point, it would be profoundly surprising if /tmp didn't
16    // already exist, since every other test makes things in there.
17    mkdirp(file, function (err, made) {
18        t.ifError(err);
19        t.equal(made, '/tmp/' + x);
20        mkdirp(file, function (err, made) {
21          t.ifError(err);
22          t.equal(made, null);
23        });
24    });
25});