aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorGravatar Tom Willemse2020-04-07 02:09:43 -0700
committerGravatar Tom Willemse2020-04-07 02:09:43 -0700
commita709f502f88821bdef956cebfb304010f46503c0 (patch)
treec55ec5fc2af75cc5408887d5ca32ad1fdfc4fc4d /test
parent378ef3d590a5227d238281f78b2521ad3dfb915a (diff)
downloademacs-config-a709f502f88821bdef956cebfb304010f46503c0.tar.gz
emacs-config-a709f502f88821bdef956cebfb304010f46503c0.zip
Add navigation functions for end-of-line and beginning-of-line
Diffstat (limited to 'test')
-rw-r--r--test/integration/oni-core.bats28
-rw-r--r--test/oni-core-test.el61
2 files changed, 89 insertions, 0 deletions
diff --git a/test/integration/oni-core.bats b/test/integration/oni-core.bats
new file mode 100644
index 0000000..7e52d86
--- /dev/null
+++ b/test/integration/oni-core.bats
@@ -0,0 +1,28 @@
+#!/usr/bin/env bats
+
+@test "Opening emacs loads oni-core" {
+ run emacs -batch -l package -f package-initialize \
+ -eval "(prin1 (featurep 'oni-core))"
+
+ echo "$output"
+
+ [[ "$output" == *"t" ]]
+}
+
+@test "C-a is bound to oni-core-move-to-beginning-of-dwim" {
+ run emacs -batch -l package -f package-initialize \
+ -eval "(prin1 (key-binding (kbd \"C-a\")))"
+
+ echo "$output"
+
+ [[ "$output" == *"oni-core-move-beginning-of-dwim" ]]
+}
+
+@test "C-e is bound to oni-core-move-to-end-of-dwim" {
+ run emacs -batch -l package -f package-initialize \
+ -eval "(prin1 (key-binding (kbd \"C-e\")))"
+
+ echo "$output"
+
+ [[ "$output" == *"oni-core-move-end-of-dwim" ]]
+}
diff --git a/test/oni-core-test.el b/test/oni-core-test.el
new file mode 100644
index 0000000..0672fb3
--- /dev/null
+++ b/test/oni-core-test.el
@@ -0,0 +1,61 @@
+(require 'oni-core)
+
+(ert-deftest oni-core-move-beginning-of-dwim-moves-to-beginning-of-indentation ()
+ "Test that ‘oni-core-move-beginning-of-dwim’ moves to the beginning of indentation."
+ (with-temp-buffer
+ (emacs-lisp-mode)
+ (insert "(defun test-defun ()\n \"Just testing a function\")")
+ (goto-char (point-max))
+ (oni-core-move-beginning-of-dwim)
+ (should (equal 24 (point)))))
+
+(ert-deftest oni-core-move-beginning-of-dwim-moves-to-beginning-of-line ()
+ "Test that ‘oni-core-move-beginning-of-dwim’ moves to the beginning of the line."
+ (with-temp-buffer
+ (emacs-lisp-mode)
+ (insert "(defun test-defun ()\n \"Just testing a function\")")
+ (goto-char (point-max))
+ (oni-core-move-beginning-of-dwim)
+ (oni-core-move-beginning-of-dwim)
+ (should (equal 22 (point)))))
+
+(ert-deftest oni-core-move-beginning-of-dwim-moves-to-beginning-of-indentation-again ()
+ "Test that ‘oni-core-move-beginning-of-dwim’ moves to the beginning of indentation again."
+ (with-temp-buffer
+ (emacs-lisp-mode)
+ (insert "(defun test-defun ()\n \"Just testing a function\")")
+ (goto-char (point-max))
+ (oni-core-move-beginning-of-dwim)
+ (oni-core-move-beginning-of-dwim)
+ (oni-core-move-beginning-of-dwim)
+ (should (equal 24 (point)))))
+
+(ert-deftest oni-core-move-end-of-dwim-moves-to-end-of-code ()
+ "Test that ‘oni-core-move-end-of-dwim’ moves to the end of the code before a comment."
+ (with-temp-buffer
+ (emacs-lisp-mode)
+ (insert "(defun test-defun () ;; Just testing\n \"Just testing a function\")")
+ (goto-char (point-min))
+ (oni-core-move-end-of-dwim)
+ (should (equal 21 (point)))))
+
+(ert-deftest oni-core-move-end-of-dwim-moves-to-end-of-line ()
+ "Test that ‘oni-core-move-end-of-dwim’ moves to the end of the line."
+ (with-temp-buffer
+ (emacs-lisp-mode)
+ (insert "(defun test-defun () ;; Just testing\n \"Just testing a function\")")
+ (goto-char (point-min))
+ (oni-core-move-end-of-dwim)
+ (oni-core-move-end-of-dwim)
+ (should (equal 38 (point)))))
+
+(ert-deftest oni-core-move-end-of-dwim-moves-to-end-of-code-again ()
+ "Test that ‘oni-core-move-end-of-dwim’ moves to the end of the code before a comment again."
+ (with-temp-buffer
+ (emacs-lisp-mode)
+ (insert "(defun test-defun () ;; Just testing\n \"Just testing a function\")")
+ (goto-char (point-min))
+ (oni-core-move-end-of-dwim)
+ (oni-core-move-end-of-dwim)
+ (oni-core-move-end-of-dwim)
+ (should (equal 21 (point)))))