This depends on [[PATCH] index-webjump: New module to define webjumps
for index pages].

The test is partially broken; it makes use of
conkeror_source_code_path to find auxiliary test files, which fails
when that variable is undefined.  For command line use ctx.local.cwd
would work, but the test suite doesn't have access to the context.
---
 tests/simple/gitweb-webjump-test.opml |   12 +++++++++
 tests/simple/index-webjump.js         |   45 +++++++++++++++++++++++++++++++++
 tests/simple/xpath-webjump-test.xhtml |   12 +++++++++
 3 files changed, 69 insertions(+), 0 deletions(-)
 create mode 100644 tests/simple/gitweb-webjump-test.opml
 create mode 100644 tests/simple/index-webjump.js
 create mode 100644 tests/simple/xpath-webjump-test.xhtml

diff --git a/tests/simple/gitweb-webjump-test.opml 
b/tests/simple/gitweb-webjump-test.opml
new file mode 100644
index 0000000..661eefc
--- /dev/null
+++ b/tests/simple/gitweb-webjump-test.opml
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="utf-8"?>
+<opml version="1.0">
+<head>
+  <title>foobar repositories OPML Export</title>
+</head>
+<body>
+<outline text="git RSS feeds">
+<outline type="rss" text="foo.git" title="foo.git" 
xmlUrl="dummy://gitweb/gitweb.cgi?p=foo.git;a=rss" 
htmlUrl="dummy://gitweb/gitweb.cgi?p=foo.git;a=summary"/>
+<outline type="rss" text="bar.git" title="bar.git" 
xmlUrl="dummy://gitweb/gitweb.cgi?p=bar.git;a=rss" 
htmlUrl="dummy://gitweb/gitweb.cgi?p=bar.git;a=summary"/>
+</outline>
+</body>
+</opml>
diff --git a/tests/simple/index-webjump.js b/tests/simple/index-webjump.js
new file mode 100644
index 0000000..cd36104
--- /dev/null
+++ b/tests/simple/index-webjump.js
@@ -0,0 +1,45 @@
+require('walnut.js');
+require('index-webjump.js');
+
+{ let suite = {
+      suite_setup: function () {
+          this.real_webjumps = webjumps;
+          this.real_index_webjumps = index_webjumps;
+          conkeror.webjumps = {};
+          conkeror.index_webjumps = {};
+      },
+      suite_teardown: function () {
+          conkeror.webjumps = this.real_webjumps;
+          conkeror.index_webjumps = this.real_index_webjumps;
+      },
+      path: conkeror_source_code_path + "/tests/simple",
+      test_xpath_webjump: function () {
+          define_xpath_webjump(
+              "xpath", "http://dummy/xpath";, '//xhtml:a...@class="index"]',
+              $index_file = this.path + '/xpath-webjump-test.xhtml');
+          assert_equals(get_webjump("xpath foo"), "foo");
+          var w = index_webjumps.xpath;
+          w.extract_completions();
+          assert_equals(w.completions.length, 2);
+          assert_equals(w.completions[0][1], "The bar");
+          assert_equals(w.completions[0][0], "http://dummy/xpath/bar";);
+          assert_equals(w.completions[1][1], "The foo");
+          assert_equals(w.completions[1][0], "http://dummy/foo";);
+      },
+      test_gitweb_webjump: function() {
+          define_gitweb_summary_webjump(
+              "gitweb", "http://dummy/gitweb";, $default = "bar",
+              $opml_file = this.path + '/gitweb-webjump-test.opml');
+          assert_equals(get_webjump("gitweb"),
+                        "http://dummy/gitweb/gitweb.cgi?p=bar.git;a=summary";);
+          assert_equals(get_webjump("gitweb foo"),
+                        "http://dummy/gitweb/gitweb.cgi?p=foo.git;a=summary";);
+          var w = index_webjumps.gitweb;
+          w.extract_completions();
+          assert_equals(w.completions.length, 2);
+          assert_equals(w.completions[0][0], "bar");
+          assert_equals(w.completions[1][0], "foo");
+      },
+  };
+  walnut_run(suite);
+}
diff --git a/tests/simple/xpath-webjump-test.xhtml 
b/tests/simple/xpath-webjump-test.xhtml
new file mode 100644
index 0000000..89e1d0b
--- /dev/null
+++ b/tests/simple/xpath-webjump-test.xhtml
@@ -0,0 +1,12 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
+<html xmlns="http://www.w3.org/1999/xhtml";>
+<head>
+<title>Dummy</title>
+</head>
+<body>
+<a class="index" href="foo">The foo</a>
+<a class="index" href="http://dummy/xpath/bar";>The bar</a>
+<a href="baz">The baz</a>
+</body>
+</html>
-- 
1.6.5

_______________________________________________
Conkeror mailing list
[email protected]
https://www.mozdev.org/mailman/listinfo/conkeror

Reply via email to