summaryrefslogtreecommitdiffstats
path: root/devtools/client/sourceeditor/tern/tests
diff options
context:
space:
mode:
Diffstat (limited to 'devtools/client/sourceeditor/tern/tests')
-rw-r--r--devtools/client/sourceeditor/tern/tests/unit/head_tern.js3
-rw-r--r--devtools/client/sourceeditor/tern/tests/unit/test_autocompletion.js26
-rw-r--r--devtools/client/sourceeditor/tern/tests/unit/test_import_tern.js16
-rw-r--r--devtools/client/sourceeditor/tern/tests/unit/xpcshell.ini8
4 files changed, 53 insertions, 0 deletions
diff --git a/devtools/client/sourceeditor/tern/tests/unit/head_tern.js b/devtools/client/sourceeditor/tern/tests/unit/head_tern.js
new file mode 100644
index 000000000..1ab102685
--- /dev/null
+++ b/devtools/client/sourceeditor/tern/tests/unit/head_tern.js
@@ -0,0 +1,3 @@
+"use strict";
+var { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
+const { require } = Cu.import("resource://devtools/shared/Loader.jsm", {});
diff --git a/devtools/client/sourceeditor/tern/tests/unit/test_autocompletion.js b/devtools/client/sourceeditor/tern/tests/unit/test_autocompletion.js
new file mode 100644
index 000000000..493d6fb18
--- /dev/null
+++ b/devtools/client/sourceeditor/tern/tests/unit/test_autocompletion.js
@@ -0,0 +1,26 @@
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+
+/**
+ * Test that tern autocompletions work.
+ */
+
+const tern = require("devtools/client/sourceeditor/tern/tern");
+const ecma5 = require("devtools/client/sourceeditor/tern/ecma5");
+
+function run_test() {
+ do_test_pending();
+
+ const server = new tern.Server({ defs: [ecma5] });
+ const code = "[].";
+ const query = { type: "completions", file: "test", end: code.length };
+ const files = [{ type: "full", name: "test", text: code }];
+
+ server.request({ query: query, files: files }, (error, response) => {
+ do_check_eq(error, null);
+ do_check_true(!!response);
+ do_check_true(Array.isArray(response.completions));
+ do_check_true(response.completions.indexOf("concat") != -1);
+ do_test_finished();
+ });
+}
diff --git a/devtools/client/sourceeditor/tern/tests/unit/test_import_tern.js b/devtools/client/sourceeditor/tern/tests/unit/test_import_tern.js
new file mode 100644
index 000000000..74f68fe60
--- /dev/null
+++ b/devtools/client/sourceeditor/tern/tests/unit/test_import_tern.js
@@ -0,0 +1,16 @@
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+
+/**
+ * Test that we can require tern.
+ */
+
+function run_test() {
+ const tern = require("devtools/client/sourceeditor/tern/tern");
+ const ecma5 = require("devtools/client/sourceeditor/tern/ecma5");
+ const browser = require("devtools/client/sourceeditor/tern/browser");
+ do_check_true(!!tern);
+ do_check_true(!!ecma5);
+ do_check_true(!!browser);
+ do_check_eq(typeof tern.Server, "function");
+}
diff --git a/devtools/client/sourceeditor/tern/tests/unit/xpcshell.ini b/devtools/client/sourceeditor/tern/tests/unit/xpcshell.ini
new file mode 100644
index 000000000..567d8524d
--- /dev/null
+++ b/devtools/client/sourceeditor/tern/tests/unit/xpcshell.ini
@@ -0,0 +1,8 @@
+[DEFAULT]
+tags = devtools
+head = head_tern.js
+tail =
+firefox-appdir = browser
+
+[test_autocompletion.js]
+[test_import_tern.js]