From 1dc4a6e2964e4045c7f6cc9fcde84503f1b9466f Mon Sep 17 00:00:00 2001 From: David Kettler Date: Mon, 13 Jul 2009 15:46:28 +0930 Subject: [PATCH] index-webjump: test suite --- tests/simple/gitweb-webjump-test.opml | 12 ++++++++ tests/simple/index-webjump.js | 52 +++++++++++++++++++++++++++++++++++ tests/simple/xpath-webjump-test.xhtml | 12 ++++++++ 3 files changed, 76 insertions(+) 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 @@ + + + + foobar repositories OPML Export + + + + + + + + diff --git a/tests/simple/index-webjump.js b/tests/simple/index-webjump.js new file mode 100644 index 0000000..8df10fe --- /dev/null +++ b/tests/simple/index-webjump.js @@ -0,0 +1,52 @@ +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"); + }, + }; + if (conkeror_source_code_path) + walnut_run(suite); + else + dumpln('Suite setup failed; conkeror_source_code_path not set.' + + ' Try:\n' + + ' conkeror -q -batch' + + ' -e "conkeror_source_code_path=\\"$PWD\\";"' + + ' -l tests/simple/index-webjump.js'); +} 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 @@ + + + +Dummy + + +The foo +The bar +The baz + + -- 2.11.4.GIT