summaryrefslogtreecommitdiff
path: root/test/parallel/test-process-chdir.js
diff options
context:
space:
mode:
authorSakthipriyan Vairamani <thechargingvolcano@gmail.com>2015-08-28 07:20:39 +0530
committerSakthipriyan Vairamani <thechargingvolcano@gmail.com>2015-09-17 04:49:47 +0530
commit9aa6a437cdeb037f8df2129f9b29230c0f4b8c2f (patch)
tree3fe27c8f766d8ba698142a3cf7ce82e660e24a2c /test/parallel/test-process-chdir.js
parent43cb1ddb006e7c13ece214d244bd362de823b8e3 (diff)
downloadnode-new-9aa6a437cdeb037f8df2129f9b29230c0f4b8c2f.tar.gz
test: use tmp directory in chdir test
This patch - makes chdir test to use the tmp directory - moves the test to parallel - renames the file to test-process-chdir as chdir is in process module PR-URL: https://github.com/nodejs/node/pull/2589 Reviewed-By: Brendan Ashworth <brendan.ashworth@me.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
Diffstat (limited to 'test/parallel/test-process-chdir.js')
-rw-r--r--test/parallel/test-process-chdir.js28
1 files changed, 28 insertions, 0 deletions
diff --git a/test/parallel/test-process-chdir.js b/test/parallel/test-process-chdir.js
new file mode 100644
index 0000000000..ed8bf83af4
--- /dev/null
+++ b/test/parallel/test-process-chdir.js
@@ -0,0 +1,28 @@
+'use strict';
+
+const common = require('../common');
+const assert = require('assert');
+const fs = require('fs');
+const path = require('path');
+
+assert.notStrictEqual(process.cwd(), __dirname);
+process.chdir(__dirname);
+assert.strictEqual(process.cwd(), __dirname);
+
+const dir = path.resolve(common.tmpDir,
+ 'weird \uc3a4\uc3ab\uc3af characters \u00e1\u00e2\u00e3');
+
+// Make sure that the tmp directory is clean
+common.refreshTmpDir();
+
+fs.mkdirSync(dir);
+process.chdir(dir);
+assert.strictEqual(process.cwd(), dir);
+
+process.chdir('..');
+assert.strictEqual(process.cwd(), path.resolve(common.tmpDir));
+
+assert.throws(function() { process.chdir({}); }, TypeError, 'Bad argument.');
+assert.throws(function() { process.chdir(); }, TypeError, 'Bad argument.');
+assert.throws(function() { process.chdir('x', 'y'); },
+ TypeError, 'Bad argument.');