From 8b5e430d385db04b21b917bb62935e8266819e38 Mon Sep 17 00:00:00 2001 From: Sean Allred Date: Thu, 1 Jan 2015 23:13:17 -0500 Subject: Add tests for search functionality --- test/test-search.el | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 test/test-search.el (limited to 'test/test-search.el') diff --git a/test/test-search.el b/test/test-search.el new file mode 100644 index 0000000..72dbcdc --- /dev/null +++ b/test/test-search.el @@ -0,0 +1,53 @@ +(defmacro test-with-bogus-string (cell &rest body) + "Let-bind a bogus string to CELL and execute BODY." + (declare (indent 1)) + `(let ((,cell "E7631BCF-A94B-4507-8F0C-02CFB3207F55")) + ,@body)) + + +(ert-deftest test-search-basic () + "Test basic search functionality" + (should + (sx-search-get-questions + "emacs" 1 "emacs"))) + +(ert-deftest test-search-empty () + "Test bogus search returns empty vector" + (test-with-bogus-string query + (should + (equal + [] + (sx-search-get-questions "emacs" 1 query))))) + +(ert-deftest test-search-invalid () + "Test invalid search" + (should-error + ;; @todo: test the interactive call + (sx-search + "emacs" nil nil ["emacs"]))) + +(ert-deftest test-search-full-page () + "Test retrieval of the full search page" + (should + (= 30 (length (sx-search-get-questions + "stackoverflow" 1 "jquery"))))) + +(ert-deftest test-search-exclude-tags () + "Test excluding tags from a search" + (should + (cl-every + (lambda (p) + (sx-assoc-let p + (not (member "org-export" .tags)))) + (sx-search-get-questions + "emacs" 1 nil "org-mode" "org-export"))) + (should + (cl-every + (lambda (p) + (sx-assoc-let p + (not (or (member "org-export" .tags) + (member "org-agenda" .tags))))) + (sx-search-get-questions + "emacs" 1 nil "org-mode" + ["org-export" "org-agenda"])))) + -- cgit v1.2.3 From aea08be5b6bf4286dacc8ae12f912f36223352f8 Mon Sep 17 00:00:00 2001 From: Sean Allred Date: Sat, 3 Jan 2015 23:16:05 -0500 Subject: Change test to reflect new default page size See eeb327e3af94e1118218c129916b8f7165e835ef. --- test/test-search.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'test/test-search.el') diff --git a/test/test-search.el b/test/test-search.el index 72dbcdc..72f0846 100644 --- a/test/test-search.el +++ b/test/test-search.el @@ -29,8 +29,8 @@ (ert-deftest test-search-full-page () "Test retrieval of the full search page" (should - (= 30 (length (sx-search-get-questions - "stackoverflow" 1 "jquery"))))) + (= 100 (length (sx-search-get-questions + "stackoverflow" 1 "jquery"))))) (ert-deftest test-search-exclude-tags () "Test excluding tags from a search" -- cgit v1.2.3