opts_fs_sync.js 799 B

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