Skip to content

Commit

Permalink
Add a unit test for deadgrep-visit-file
Browse files Browse the repository at this point in the history
  • Loading branch information
Wilfred authored and gvol committed Feb 11, 2021
1 parent b27ba94 commit 3eada3b
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions test/deadgrep-unit-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,14 @@ some results."
(eq (get-text-property (point) 'face)
'deadgrep-match-face))))

(ert-deftest deadgrep-visit-result ()
"`deadgrep-visit-result' should open the file at point."
(with-temp-deadgrep-buf
(deadgrep-forward-match)
(deadgrep-visit-result)
(let ((buf-name (buffer-file-name)))
(should (s-ends-with-p "deadgrep.el" buf-name)))))

(ert-deftest deadgrep--split-line ()
(-let* ((raw-line
"deadgrep.el:123: (when (buffer-live-p buffer)")
Expand Down Expand Up @@ -466,11 +474,11 @@ edit mode."
(let ((deadgrep--file-type 'tests))
(should
(equal (deadgrep--arguments "foo" 'string 'sensitive '(1 . 0))
'("--color=ansi" "--line-number" "--no-heading" "--with-filename" "--fixed-strings" "--case-sensitive" "--type=TEST" "--before-context=1" "--after-context=0" "--" "foo" "."))))
'("--color=ansi" "--line-number" "--no-heading" "--no-column" "--with-filename" "--fixed-strings" "--case-sensitive" "--type=TEST" "--before-context=1" "--after-context=0" "--" "foo" "."))))
(let ((deadgrep--file-type 'no-tests))
(should
(equal (deadgrep--arguments "foo" 'string 'sensitive '(1 . 0))
'("--color=ansi" "--line-number" "--no-heading" "--with-filename" "--fixed-strings" "--case-sensitive" "--type-not=TEST" "--before-context=1" "--after-context=0" "--" "foo" ".")))))
'("--color=ansi" "--line-number" "--no-heading" "--no-column" "--with-filename" "--fixed-strings" "--case-sensitive" "--type-not=TEST" "--before-context=1" "--after-context=0" "--" "foo" ".")))))
)

(ert-deftest deadgrep--arguments-error-cases ()
Expand Down

0 comments on commit 3eada3b

Please sign in to comment.