nodejs-mkdirp/nodejs-mkdirp-mockfs4.patch
2020-08-24 09:14:14 +08:00

61 lines
1.9 KiB
Diff

commit 0cd6cd55664b5979fd546d6f9ae1fbf383a6eaed
Author: Tom Hughes <tom@compton.nu>
Date: Mon Feb 6 09:35:46 2017 +0000
Adjust tests for mockfs 4.x changes
diff --git a/test/opts_fs.js b/test/opts_fs.js
index 97186b6..0e9f8ee 100644
--- a/test/opts_fs.js
+++ b/test/opts_fs.js
@@ -2,6 +2,7 @@ var mkdirp = require('../');
var path = require('path');
var test = require('tap').test;
var mockfs = require('mock-fs');
+var xfs = require('fs');
var _0777 = parseInt('0777', 8);
var _0755 = parseInt('0755', 8);
@@ -12,9 +13,11 @@ test('opts.fs', function (t) {
var y = Math.floor(Math.random() * Math.pow(16,4)).toString(16);
var z = Math.floor(Math.random() * Math.pow(16,4)).toString(16);
- var file = '/beep/boop/' + [x,y,z].join('/');
- var xfs = mockfs.fs();
-
+ var file = 'beep/boop/' + [x,y,z].join('/');
+
+ mockfs();
+ t.tearDown(mockfs.restore);
+
mkdirp(file, { fs: xfs, mode: _0755 }, function (err) {
t.ifError(err);
xfs.exists(file, function (ex) {
diff --git a/test/opts_fs_sync.js b/test/opts_fs_sync.js
index 6c370aa..b8cf63a 100644
--- a/test/opts_fs_sync.js
+++ b/test/opts_fs_sync.js
@@ -2,6 +2,7 @@ var mkdirp = require('../');
var path = require('path');
var test = require('tap').test;
var mockfs = require('mock-fs');
+var xfs = require('fs');
var _0777 = parseInt('0777', 8);
var _0755 = parseInt('0755', 8);
@@ -12,9 +13,11 @@ test('opts.fs sync', function (t) {
var y = Math.floor(Math.random() * Math.pow(16,4)).toString(16);
var z = Math.floor(Math.random() * Math.pow(16,4)).toString(16);
- var file = '/beep/boop/' + [x,y,z].join('/');
- var xfs = mockfs.fs();
-
+ var file = 'beep/boop/' + [x,y,z].join('/');
+
+ mockfs();
+ t.tearDown(mockfs.restore);
+
mkdirp.sync(file, { fs: xfs, mode: _0755 });
xfs.exists(file, function (ex) {
t.ok(ex, 'created file');