summaryrefslogtreecommitdiffstats
path: root/devtools/client/sourceeditor/tern/tests/unit/test_autocompletion.js
blob: 493d6fb18f02f42d172a3a31aa12426c7ed7a1d0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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();
  });
}