test-folding.el
1 ;;; test-folding.el --- Tests for treesit-fold configuration -*- lexical-binding: t; -*- 2 ;;; Commentary: 3 ;; Tests for treesit-fold code folding setup. 4 ;;; Code: 5 6 (describe "treesit-fold availability" 7 (it "treesit-fold feature is provided" 8 (expect (featurep 'treesit-fold) :to-be t)) 9 10 (it "core folding functions are defined" 11 (dolist (fn '(treesit-fold-toggle 12 treesit-fold-close-all 13 treesit-fold-open-all 14 treesit-fold-open-recursively)) 15 (expect (fboundp fn) :to-be t)))) 16 17 (describe "global fold modes" 18 (it "global-treesit-fold-mode is enabled" 19 (expect global-treesit-fold-mode :not :to-be nil)) 20 21 (it "global-treesit-fold-indicators-mode is enabled" 22 (expect global-treesit-fold-indicators-mode :not :to-be nil))) 23 24 (describe "fold keybindings" 25 (it "C-c t is bound to treesit-fold prefix command" 26 (expect (global-key-binding (kbd "C-c t")) 27 :to-equal 'treesit-fold-prefix-command)) 28 29 (it "C-c t t is bound to treesit-fold-toggle via prefix" 30 (expect (lookup-key treesit-fold-prefix-command (kbd "t")) 31 :to-equal 'treesit-fold-toggle)) 32 33 (it "C-c t c is bound to treesit-fold-close-all via prefix" 34 (expect (lookup-key treesit-fold-prefix-command (kbd "c")) 35 :to-equal 'treesit-fold-close-all)) 36 37 (it "C-c t o is bound to treesit-fold-open-all via prefix" 38 (expect (lookup-key treesit-fold-prefix-command (kbd "o")) 39 :to-equal 'treesit-fold-open-all)) 40 41 (it "C-c t r is bound to treesit-fold-open-recursively via prefix" 42 (expect (lookup-key treesit-fold-prefix-command (kbd "r")) 43 :to-equal 'treesit-fold-open-recursively))) 44 45 (describe "treesit-fold parser support" 46 (it "has fold range parsers for key modes" 47 (dolist (mode '(python-ts-mode yaml-ts-mode json-ts-mode 48 bash-ts-mode css-ts-mode go-ts-mode)) 49 (expect (assoc mode treesit-fold-range-alist) :not :to-be nil)))) 50 51 (provide 'test-folding) 52 ;;; test-folding.el ends here