Working test setup which also tests preview

This commit is contained in:
Carlo Sciolla 2016-11-11 12:53:41 +01:00
parent 1b8100d9b0
commit a143ab5d7d
No known key found for this signature in database
GPG Key ID: BA5D71E6F3C580C1
7 changed files with 74 additions and 0 deletions

BIN
bin/plantuml.jar Normal file

Binary file not shown.

View File

@ -0,0 +1,23 @@
;;; plantuml-mode-custom-jar-location-test.el --- PlantUML Mode JAR location tests -*- lexical-binding: t; -*-
;; Author: Carlo Sciolla (skuro)
;; Maintainer: Carlo Sciolla (skuro)
;; URL: https://github.com/skuro/plantuml-mode
;;; Commentary:
;;; Code:
(ert-deftest custom-jar-location ()
(setq-local plantuml-jar-path "~/.plantuml/plantuml.jar")
(should (equal `("-Djava.awt.headless=true" "-jar"
,(expand-file-name "~/.plantuml/plantuml.jar"))
(plantuml-render-command)))
(setq-local plantuml-jar-path "/path/with spaces/plantuml.jar")
(should (equal `("-Djava.awt.headless=true" "-jar" "/path/with spaces/plantuml.jar")
(plantuml-render-command))))
(provide 'plantuml-mode-custom-jar-location-test)
;;; plantuml-mode-custom-jar-location-test.el ends here

View File

@ -12,4 +12,6 @@
(should (equal (expand-file-name "~/plantuml.jar")
plantuml-jar-path)))
(provide 'plantuml-mode-test)
;;; plantuml-mode-test.el ends here

View File

@ -0,0 +1,20 @@
;;; plantuml-mode-preview-test.el --- PlantUML Mode preview tests -*- lexical-binding: t; -*-
;; Author: Carlo Sciolla (skuro)
;; Maintainer: Carlo Sciolla (skuro)
;; URL: https://github.com/skuro/plantuml-mode
;;; Commentary:
;;; Code:
(ert-deftest preview-test ()
(setq-local plantuml-jar-path plantuml-test-jar-path)
(setq-local plantuml-output-type "utxt")
(plantuml-preview-string 42 (read-test-file "a-b.puml"))
(sleep-for 2)
(should (equal (read-test-file "a-b.txt") (read-preview-buffer))))
(provide 'plantuml-mode-preview-test)
;;; plantuml-mode-preview-test.el ends here

5
test/resources/a-b.puml Normal file
View File

@ -0,0 +1,5 @@
@startuml
A -> B
@enduml

8
test/resources/a-b.txt Normal file
View File

@ -0,0 +1,8 @@
┌─┐ ┌─┐
│A│ │B│
└┬┘ └┬┘
│ │
│───────────>│
┌┴┐ ┌┴┐
│A│ │B│
└─┘ └─┘

View File

@ -16,6 +16,22 @@
(defvar package-code-path
(f-parent package-test-path))
(defvar plantuml-test-resources-path
(f-join package-code-path "test/resources"))
(defvar plantuml-test-jar-path
(f-join package-code-path "bin/plantuml.jar"))
(defun read-buffer (bufname)
(with-current-buffer (get-buffer bufname)
(buffer-string)))
(defun read-preview-buffer ()
(read-buffer plantuml-preview-buffer))
(defun read-test-file (path)
(f-read (f-join plantuml-test-resources-path path) 'utf-8))
(require 'plantuml-mode (f-expand "plantuml-mode.el" package-code-path))
;;; test-helper.el ends here