Skip to content

Commit

Permalink
Add hsettings tests (#452)
Browse files Browse the repository at this point in the history
  • Loading branch information
matsl authored Jan 20, 2024
1 parent dd2e088 commit 44b5b44
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 0 deletions.
3 changes: 3 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
2024-01-20 Mats Lidell <[email protected]>

* test/hsettings-test.el: New test file for hsettings.
(hsettings-test--hyperbole-web-search): Test hyperbole-web-search.

* Makefile (package-lint): Add explicit loading of package-lint from Melpa
for this target. Only needed there.

Expand Down
1 change: 1 addition & 0 deletions test/MANIFEST
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ hibtypes-tests.el - unit test for hib-kbd
hmouse-drv-tests.el - hmouse-drv unit tests
hmouse-info-tests.el - hmouse-info unit tests
hpath-tests.el - unit tests for hpath
hsettings-test.el - unit tests for hsettings
hsys-org-tests.el - hsys-org tests
hui-register-tests.el - test for hui-register
hui-select-tests.el - hui-select tests
Expand Down
46 changes: 46 additions & 0 deletions test/hsettings-test.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
;;; hsettings-test.el --- one line summary -*- lexical-binding: t; -*-
;;
;; Author: Mats Lidell
;;
;; Orig-Date: 20-Jan-24 at 12:28:01
;; Last-Mod: 20-Jan-24 at 14:25:44 by Mats Lidell
;;
;; SPDX-License-Identifier: GPL-3.0-or-later
;;
;; Copyright (C) 2024 Free Software Foundation, Inc.
;; See the "HY-COPY" file for license information.
;;
;; This file is part of GNU Hyperbole.

;;; Commentary:
;;

;;; Code:

(require 'ert)
(require 'el-mock)
(require 'hsettings)

(ert-deftest hsettings-test--hyperbole-web-search ()
"Verify `hyperbole-web-search´."
(mocklet (((browse-url "http://www.google.com/search?q=hyperbole") => "return"))
(should (string= (hyperbole-web-search "google" "hyperbole" nil) "return")))
(should (string= (hyperbole-web-search "google" "hyperbole" t) "http://www.google.com/search?q=hyperbole"))
(should-error (hyperbole-web-search "unknown" "hyperbole" nil))
(should-error (hyperbole-web-search "unknown" "hyperbole" t))

;; Jump
;; Fails due to being called with argument: See test below.
;; (mocklet (((webjump) => "return"))
;; (should (string= (hyperbole-web-search "Jump" "arg" nil) "return")))
(should (equal (hyperbole-web-search "Jump" "arg" t) '(webjump "arg"))))

(ert-deftest hsettings-test--hyperbole-web-search-webjump-called-with-arg ()
"Verify `hyperbole-web-search´."
:expected-result :failed
;; Jump
(mocklet (((webjump) => "return"))
(should (string= (hyperbole-web-search "Jump" "arg" nil) "return"))))

(provide 'hsettings-test)
;;; hsettings-test.el ends here

0 comments on commit 44b5b44

Please sign in to comment.