Skip to content

Commit 6d9d81b

Browse files
committed
Add tests for clojure-toggle-keyword-string
1 parent 8c1389c commit 6d9d81b

1 file changed

Lines changed: 74 additions & 0 deletions

File tree

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
;;; clojure-mode-toggle-keyword-string-test.el --- Clojure Mode: toggle keyword/string tests -*- lexical-binding: t; -*-
2+
3+
;; Copyright (C) 2026 Bozhidar Batsov <bozhidar@batsov.dev>
4+
5+
;; This file is not part of GNU Emacs.
6+
7+
;; This program is free software; you can redistribute it and/or modify
8+
;; it under the terms of the GNU General Public License as published by
9+
;; the Free Software Foundation, either version 3 of the License, or
10+
;; (at your option) any later version.
11+
12+
;; This program is distributed in the hope that it will be useful,
13+
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
;; GNU General Public License for more details.
16+
17+
;; You should have received a copy of the GNU General Public License
18+
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
19+
20+
;;; Commentary:
21+
22+
;; Tests for clojure-toggle-keyword-string.
23+
24+
;;; Code:
25+
26+
(require 'clojure-mode)
27+
(require 'buttercup)
28+
(require 'test-helper "test/utils/test-helper")
29+
30+
(describe "clojure-toggle-keyword-string"
31+
32+
(it "should convert a keyword to a string"
33+
(with-clojure-buffer-point "{:|foo 1}"
34+
(clojure-toggle-keyword-string)
35+
(expect (buffer-string) :to-equal "{\"foo\" 1}")))
36+
37+
(it "should convert a string to a keyword"
38+
(with-clojure-buffer-point "{|\"foo\" 1}"
39+
(clojure-toggle-keyword-string)
40+
(expect (buffer-string) :to-equal "{:foo 1}")))
41+
42+
(it "should convert a keyword with point in the middle"
43+
(with-clojure-buffer-point "{:fo|o 1}"
44+
(clojure-toggle-keyword-string)
45+
(expect (buffer-string) :to-equal "{\"foo\" 1}")))
46+
47+
(it "should convert a string with point in the middle"
48+
(with-clojure-buffer-point "{\"fo|o\" 1}"
49+
(clojure-toggle-keyword-string)
50+
(expect (buffer-string) :to-equal "{:foo 1}")))
51+
52+
(it "should handle a keyword with hyphens"
53+
(with-clojure-buffer-point "{:|foo-bar 1}"
54+
(clojure-toggle-keyword-string)
55+
(expect (buffer-string) :to-equal "{\"foo-bar\" 1}")))
56+
57+
(it "should handle a string with hyphens"
58+
(with-clojure-buffer-point "{|\"foo-bar\" 1}"
59+
(clojure-toggle-keyword-string)
60+
(expect (buffer-string) :to-equal "{:foo-bar 1}")))
61+
62+
(it "should handle a keyword with dots"
63+
(with-clojure-buffer-point "{:|foo.bar 1}"
64+
(clojure-toggle-keyword-string)
65+
(expect (buffer-string) :to-equal "{\"foo.bar\" 1}")))
66+
67+
(it "should handle a namespaced keyword"
68+
(with-clojure-buffer-point "{:|foo/bar 1}"
69+
(clojure-toggle-keyword-string)
70+
(expect (buffer-string) :to-equal "{\"foo/bar\" 1}"))))
71+
72+
(provide 'clojure-mode-toggle-keyword-string-test)
73+
74+
;;; clojure-mode-toggle-keyword-string-test.el ends here

0 commit comments

Comments
 (0)