summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAnto Aravinth <anto.aravinth.cse@gmail.com>2019-04-25 20:14:47 +0530
committerAnto Aravinth <anto.aravinth.cse@gmail.com>2019-04-29 07:28:27 +0530
commitd69f00465790f1ac7788ac111bb61689543536ae (patch)
tree33bb84b6f50b5d29198bfa82aca628b6d6a28425 /test
parent377939eef847d2475768c0db0b3eb1a699f545f1 (diff)
downloadandroid-node-v8-d69f00465790f1ac7788ac111bb61689543536ae.tar.gz
android-node-v8-d69f00465790f1ac7788ac111bb61689543536ae.tar.bz2
android-node-v8-d69f00465790f1ac7788ac111bb61689543536ae.zip
repl: add autocomplete for filesystem modules
PR-URL: https://github.com/nodejs/node/pull/26648 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Diffstat (limited to 'test')
-rw-r--r--test/fixtures/test-repl-tab-completion/.hiddenfiles1
-rw-r--r--test/fixtures/test-repl-tab-completion/hellorandom.txt1
-rw-r--r--test/fixtures/test-repl-tab-completion/helloworld.js1
-rw-r--r--test/parallel/test-repl-tab-complete.js39
4 files changed, 42 insertions, 0 deletions
diff --git a/test/fixtures/test-repl-tab-completion/.hiddenfiles b/test/fixtures/test-repl-tab-completion/.hiddenfiles
new file mode 100644
index 0000000000..8943faefed
--- /dev/null
+++ b/test/fixtures/test-repl-tab-completion/.hiddenfiles
@@ -0,0 +1 @@
+This is hidden \ No newline at end of file
diff --git a/test/fixtures/test-repl-tab-completion/hellorandom.txt b/test/fixtures/test-repl-tab-completion/hellorandom.txt
new file mode 100644
index 0000000000..35268b4f15
--- /dev/null
+++ b/test/fixtures/test-repl-tab-completion/hellorandom.txt
@@ -0,0 +1 @@
+Random txt \ No newline at end of file
diff --git a/test/fixtures/test-repl-tab-completion/helloworld.js b/test/fixtures/test-repl-tab-completion/helloworld.js
new file mode 100644
index 0000000000..0f504264f5
--- /dev/null
+++ b/test/fixtures/test-repl-tab-completion/helloworld.js
@@ -0,0 +1 @@
+console.log("hello world"); \ No newline at end of file
diff --git a/test/parallel/test-repl-tab-complete.js b/test/parallel/test-repl-tab-complete.js
index 02cd06c953..364d880e8c 100644
--- a/test/parallel/test-repl-tab-complete.js
+++ b/test/parallel/test-repl-tab-complete.js
@@ -397,6 +397,45 @@ testMe.complete('obj.', common.mustCall((error, data) => {
assert(data[0].includes('obj.key'));
}));
+// Tab completion for files/directories
+{
+ putIn.run(['.clear']);
+ process.chdir(__dirname);
+
+ const readFileSync = 'fs.readFileSync("';
+ const fixturePath = `${readFileSync}../fixtures/test-repl-tab-completion`;
+ if (!common.isWindows) {
+ testMe.complete(fixturePath, common.mustCall((err, data) => {
+ assert.strictEqual(err, null);
+ assert.ok(data[0][0].includes('.hiddenfiles'));
+ assert.ok(data[0][1].includes('hellorandom.txt'));
+ assert.ok(data[0][2].includes('helloworld.js'));
+ }));
+
+ testMe.complete(`${fixturePath}/hello`,
+ common.mustCall((err, data) => {
+ assert.strictEqual(err, null);
+ assert.ok(data[0][0].includes('hellorandom.txt'));
+ assert.ok(data[0][1].includes('helloworld.js'));
+ })
+ );
+
+ testMe.complete(`${fixturePath}/.h`,
+ common.mustCall((err, data) => {
+ assert.strictEqual(err, null);
+ assert.ok(data[0][0].includes('.hiddenfiles'));
+ })
+ );
+
+ testMe.complete(`${readFileSync}./xxxRandom/random`,
+ common.mustCall((err, data) => {
+ assert.strictEqual(err, null);
+ assert.strictEqual(data[0].length, 0);
+ })
+ );
+ }
+}
+
[
Array,
Buffer,