index-webjump: insist on completions being available
[conkeror.git] / tests / simple / index-webjump.js
blob6b9375c6f1bac207d80791ee5b7374a936425049
1 require('walnut.js');
2 require('index-webjump.js');
4 { let suite = {
5       suite_setup: function () {
6           this.real_webjumps = webjumps;
7           this.real_index_webjumps = index_webjumps;
8           conkeror.webjumps = {};
9           conkeror.index_webjumps = {};
10       },
11       suite_teardown: function () {
12           conkeror.webjumps = this.real_webjumps;
13           conkeror.index_webjumps = this.real_index_webjumps;
14       },
15       path: conkeror_source_code_path + "/tests/simple",
16       test_xpath_webjump: function () {
17           define_xpath_webjump(
18               "xpath", "http://dummy/xpath", '//xhtml:a[@class="index"]',
19               $index_file = this.path + '/xpath-webjump-test.xhtml');
20           var w = index_webjumps.xpath;
21           w.extract_completions();
22           assert_equals(get_webjump("xpath foo"), "foo");
23           assert_equals(w.completions.length, 2);
24           assert_equals(w.completions[0][1], "The bar");
25           assert_equals(w.completions[0][0], "http://dummy/xpath/bar");
26           assert_equals(w.completions[1][1], "The foo");
27           assert_equals(w.completions[1][0], "http://dummy/foo");
28       },
29       test_gitweb_webjump: function() {
30           define_gitweb_summary_webjump(
31               "gitweb", "http://dummy/gitweb", $default = "bar",
32               $opml_file = this.path + '/gitweb-webjump-test.opml');
33           assert_equals(get_webjump("gitweb"),
34                         "http://dummy/gitweb/gitweb.cgi?p=bar.git;a=summary");
35           assert_equals(get_webjump("gitweb foo"),
36                         "http://dummy/gitweb/gitweb.cgi?p=foo.git;a=summary");
37           var w = index_webjumps.gitweb;
38           w.extract_completions();
39           assert_equals(w.completions.length, 2);
40           assert_equals(w.completions[0][0], "bar");
41           assert_equals(w.completions[1][0], "foo");
42       },
43   };
44   if (conkeror_source_code_path)
45       walnut_run(suite);
46   else
47       dumpln('Suite setup failed; conkeror_source_code_path not set.' +
48              '  Try:\n' +
49              '  conkeror -q -batch' +
50              ' -e "conkeror_source_code_path=\\"$PWD\\";"' +
51              ' -l tests/simple/index-webjump.js');