summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDavid Shepherd <davidshepherd7@gmail.com>2017-03-16 11:22:27 +0000
committerDavid Shepherd <davidshepherd7@gmail.com>2017-03-16 11:22:27 +0000
commit58d9f38bc10cac5787125a247f3115f6b5222bb7 (patch)
treea1c533cd40191731a40baf7655b9ab742acb1d6a /test
parentAdd build system (diff)
downloademacs-terminal-here-58d9f38bc10cac5787125a247f3115f6b5222bb7.tar.gz
Initial probably-working version
Diffstat (limited to 'test')
-rw-r--r--test/terminal-here-test.el40
-rw-r--r--test/test-helper.el13
2 files changed, 53 insertions, 0 deletions
diff --git a/test/terminal-here-test.el b/test/terminal-here-test.el
new file mode 100644
index 0000000..2eb9471
--- /dev/null
+++ b/test/terminal-here-test.el
@@ -0,0 +1,40 @@
+;;; -*- lexical-binding: t; -*-
+
+(ert-deftest linux-default-command ()
+ (with-mock
+ (mock (start-process "x-terminal-emulator" * "x-terminal-emulator"))
+ (let ((system-type 'gnu/linux))
+ (custom-reevaluate-setting 'terminal-here-terminal-command)
+ (terminal-here-launch-in-directory "adir"))))
+
+(ert-deftest osx-default-command ()
+ (with-mock
+ (mock (start-process "open" * "open" "-a" "Terminal.app" "adir"))
+ (let ((system-type 'darwin))
+ (custom-reevaluate-setting 'terminal-here-terminal-command)
+ (terminal-here-launch-in-directory "adir"))))
+
+(ert-deftest windows-default-command ()
+ (with-mock
+ (mock (start-process "start" * "start" "/D" "adir" "cmd"))
+ (let ((system-type 'windows-nt))
+ (custom-reevaluate-setting 'terminal-here-terminal-command)
+ (terminal-here-launch-in-directory "adir"))))
+
+(ert-deftest custom-terminal-command-as-list ()
+ (with-mock
+ (mock (start-process "1" * "1" "2" "3"))
+ (validate-setq terminal-here-terminal-command '("1" "2" "3"))
+ (terminal-here-launch-in-directory "adir")))
+
+(ert-deftest custom-terminal-command-as-function ()
+ (with-mock
+ (mock (start-process "1" * "1" "2" "3" "adir"))
+ (validate-setq terminal-here-terminal-command (lambda (dir) (list "1" "2" "3" dir)))
+ (terminal-here-launch-in-directory "adir")))
+
+(ert-deftest custom-terminal-command-as-junk-rejected ()
+ (with-mock
+ (should-error
+ (validate-setq terminal-here-terminal-command "astring")
+ :type 'user-error)))
diff --git a/test/test-helper.el b/test/test-helper.el
new file mode 100644
index 0000000..2ecee3b
--- /dev/null
+++ b/test/test-helper.el
@@ -0,0 +1,13 @@
+;; Don't load old byte-compiled versions!
+(setq load-prefer-newer t)
+
+;; Load terminal-here
+(require 'f)
+(add-to-list 'load-path (f-parent (f-dirname load-file-name)))
+(require 'terminal-here)
+
+;; Load test helpers
+(require 'el-mock)
+(eval-when-compile
+ (require 'cl)) ;; for el-mock
+(require 'validate)