all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
blob cf917802e0d2c1737bd19a9630df8366e054d20f 4996 bytes (raw)
name: test/lisp/net/browse-url-tests.el 	 # note: path name is non-authoritative(*)

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
 
;;; browse-url-tests.el --- Tests for browse-url.el  -*- lexical-binding: t; -*-

;; Copyright (C) 2020-2022 Free Software Foundation, Inc.

;; Author: Simen Heggestøyl <simenheg@gmail.com>
;; Keywords:

;; This file is part of GNU Emacs.

;; GNU Emacs is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.

;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.

;;; Commentary:

;;

;;; Code:

(require 'browse-url)
(require 'ert)
(require 'ert-x)

(ert-deftest browse-url-tests-browser-kind ()
  (should (eq (browse-url--browser-kind #'browse-url-emacs "gnu.org")
              'internal))
  (should
   (eq (browse-url--browser-kind #'browse-url-firefox "gnu.org")
       'external)))

(ert-deftest browse-url-tests-non-html-file-url-p ()
  (should (browse-url--non-html-file-url-p "file://foo.txt"))
  (should-not (browse-url--non-html-file-url-p "file://foo.html")))

(ert-deftest browse-url-tests-select-handler-mailto ()
  (should (eq (browse-url-select-handler "mailto:foo@bar.org")
              'browse-url--mailto))
  (should (eq (browse-url-select-handler "mailto:foo@bar.org"
                                         'internal)
              'browse-url--mailto))
  (should-not (browse-url-select-handler "mailto:foo@bar.org"
                                         'external)))

(ert-deftest browse-url-tests-select-handler-man ()
  (should (eq (browse-url-select-handler "man:ls") 'browse-url--man))
  (should (eq (browse-url-select-handler "man:ls" 'internal)
              'browse-url--man))
  (should-not (browse-url-select-handler "man:ls" 'external)))

(ert-deftest browse-url-tests-select-handler-irc ()
  (should (eq (browse-url-select-handler "irc://localhost" 'internal)
              'browse-url-irc))
  (should-not (browse-url-select-handler "irc://localhost" 'external))
  (should (eq (browse-url-select-handler "irc6://localhost")
              'browse-url-irc))
  (should (eq (browse-url-select-handler "ircs://tester@irc.gnu.org/#chan")
              'browse-url-irc)))

(ert-deftest browse-url-tests-select-handler-file ()
  (should (eq (browse-url-select-handler "file://foo.txt")
              'browse-url-emacs))
  (should (eq (browse-url-select-handler "file://foo.txt" 'internal)
              'browse-url-emacs))
  (should-not (browse-url-select-handler "file://foo.txt" 'external)))

(ert-deftest browse-url-tests-url-encode-chars ()
  (should (equal (browse-url-url-encode-chars "foobar" "[ob]")
                 "f%6F%6F%62ar")))

(ert-deftest browse-url-tests-encode-url ()
  (should (equal (browse-url-encode-url "") ""))
  (should (equal (browse-url-encode-url "a b c") "a%20b%20c"))
  (should (equal (browse-url-encode-url "\"a\" \"b\"")
                 "%22a%22%20%22b%22"))
  (should (equal (browse-url-encode-url "(a) (b)") "%28a%29%20%28b%29"))
  (should (equal (browse-url-encode-url "a$ b$") "a$%20b$")))

(ert-deftest browse-url-tests-url-at-point ()
  (with-temp-buffer
    (insert "gnu.org")
    (should (equal (browse-url-url-at-point) "http://gnu.org"))))

(ert-deftest browse-url-tests-file-url ()
  (should (equal (browse-url-file-url "/foo") "file:///foo"))
  (when (file-remote-p "/foo:")
    (should (equal (browse-url-file-url "/foo:") "ftp://foo/")))
  (when (file-remote-p "/ftp@foo:")
    (should (equal (browse-url-file-url "/ftp@foo:") "ftp://foo/")))
  (when (file-remote-p "/anonymous@foo:")
    (should (equal (browse-url-file-url "/anonymous@foo:")
                   "ftp://foo/"))))

(ert-deftest browse-url-tests-delete-temp-file ()
  (ert-with-temp-file browse-url-temp-file-name
    (browse-url-delete-temp-file)
    (should-not (file-exists-p browse-url-temp-file-name)))
  (ert-with-temp-file file
    (browse-url-delete-temp-file file)
    (should-not (file-exists-p file))))

(ert-deftest browse-url-tests-add-buttons ()
  (with-temp-buffer
    (insert "Visit https://gnu.org")
    (goto-char (point-min))
    (browse-url-add-buttons)
    (goto-char (- (point-max) 1))
    (should (eq (get-text-property (point) 'face)
                'browse-url-button))
    (should (get-text-property (point) 'browse-url-data))))

(ert-deftest browse-url-tests-button-copy ()
  (with-temp-buffer
    (insert "Visit https://gnu.org")
    (goto-char (point-min))
    (browse-url-add-buttons)
    (should-error (browse-url-button-copy))
    (goto-char (- (point-max) 1))
    (browse-url-button-copy)
    (should (equal (car kill-ring) "https://gnu.org"))))

(provide 'browse-url-tests)
;;; browse-url-tests.el ends here

debug log:

solving cf917802e0 ...
found cf917802e0 in https://yhetil.org/emacs/87pmdxlera.fsf@neverwas.me/
found 1c993958b8 in https://git.savannah.gnu.org/cgit/emacs.git
preparing index
index prepared:
100644 1c993958b8101b8f1bb0202db57fea890d72d7d7	test/lisp/net/browse-url-tests.el

applying [1/1] https://yhetil.org/emacs/87pmdxlera.fsf@neverwas.me/
diff --git a/test/lisp/net/browse-url-tests.el b/test/lisp/net/browse-url-tests.el
index 1c993958b8..cf917802e0 100644

Checking patch test/lisp/net/browse-url-tests.el...
Applied patch test/lisp/net/browse-url-tests.el cleanly.

skipping https://yhetil.org/emacs/87pmdxlera.fsf@neverwas.me/ for cf917802e0
index at:
100644 cf917802e0d2c1737bd19a9630df8366e054d20f	test/lisp/net/browse-url-tests.el

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.