rel.js 921 B

1234567891011121314151617181920212223242526272829303132
  1. /* Tests borrowed from substack's node-mkdirp
  2. * https://github.com/substack/node-mkdirp */
  3. var mkpath = require('../');
  4. var fs = require('fs');
  5. var test = require('tap').test;
  6. test('rel', function (t) {
  7. t.plan(2);
  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. var cwd = process.cwd();
  12. process.chdir('/tmp');
  13. var file = [x,y,z].join('/');
  14. mkpath(file, 0755, function (err) {
  15. if (err) t.fail(err);
  16. else fs.stat(file, function (err, stat) {
  17. if (err) t.fail(err)
  18. else {
  19. process.chdir(cwd);
  20. t.equal(stat.mode & 0777, 0755);
  21. t.ok(stat.isDirectory(), 'target not a directory');
  22. t.end();
  23. }
  24. })
  25. });
  26. });