UNPKG

868 BJavaScriptView Raw
1var mkdirp = require('../');
2var path = require('path');
3var test = require('tap').test;
4var mockfs = require('mock-fs');
5var _0777 = parseInt('0777', 8);
6var _0755 = parseInt('0755', 8);
7
8test('opts.fs sync', function (t) {
9 t.plan(4);
10
11 var x = Math.floor(Math.random() * Math.pow(16,4)).toString(16);
12 var y = Math.floor(Math.random() * Math.pow(16,4)).toString(16);
13 var z = Math.floor(Math.random() * Math.pow(16,4)).toString(16);
14
15 var file = '/beep/boop/' + [x,y,z].join('/');
16 var xfs = mockfs.fs();
17
18 mkdirp.sync(file, { fs: xfs, mode: _0755 });
19 xfs.exists(file, function (ex) {
20 t.ok(ex, 'created file');
21 xfs.stat(file, function (err, stat) {
22 t.ifError(err);
23 t.equal(stat.mode & _0777, _0755);
24 t.ok(stat.isDirectory(), 'target not a directory');
25 });
26 });
27});