Last active
September 20, 2016 06:37
-
-
Save bryanwb/7af33b1ce0ea3cce150116ff6ccba87b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; use-region-p returns nil even though it is mocked using cl-flet | |
;; why? | |
(defun bwb-gitlab--get-line-nums () | |
"Return line number(s) if applicable. | |
If region selected, returns range in url form" | |
(if (null (use-region-p)) | |
(message "use-region-p is nil")) | |
(cond ((not (gitlab--viewing-filep)) "") | |
((use-region-p) | |
(format "#L%d-%d" | |
(line-number-at-pos (region-beginning)) | |
(line-number-at-pos (region-end)))) | |
(t | |
(format "#L%d" (line-number-at-pos (point)))))) | |
(ert-deftest test-gitlab-determine-linenum () | |
:tags '(browse) | |
(cl-flet ((use-region-p () t)) | |
(save-excursion | |
(let ((buffer (find-file-noselect gitlab-readme))) | |
(set-buffer buffer) | |
(forward-line) | |
(forward-line) | |
(set-mark-command (point)) | |
(beginning-of-buffer) | |
(should (s-equals? (bwb-gitlab--get-line-nums) "#L1-2")) | |
)))) | |
;; actual result of (bwb-gitlab--get-line-nums) => "#L1" | |
;; and message "use-region-p" is nil shown |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment