test-ob-plantuml.el 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. ;;; test-ob-plantuml.el --- tests for ob-plantuml.el
  2. ;; Copyright (c) 2016 Thibault Marin
  3. ;; Authors: Thibault Marin
  4. ;; This file is not part of GNU Emacs.
  5. ;; This program is free software; you can redistribute it and/or modify
  6. ;; it under the terms of the GNU General Public License as published by
  7. ;; the Free Software Foundation, either version 3 of the License, or
  8. ;; (at your option) any later version.
  9. ;; This program is distributed in the hope that it will be useful,
  10. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. ;; GNU General Public License for more details.
  13. ;; You should have received a copy of the GNU General Public License
  14. ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. ;;; Code:
  16. (unless (featurep 'ob-plantuml)
  17. (signal 'missing-test-dependency "Support for PlantUML code blocks"))
  18. (ert-deftest test-ob-plantuml/single-var ()
  19. "Test file output with input variable."
  20. (should
  21. (string=
  22. "@startuml
  23. !define CLASSNAME test_class
  24. class CLASSNAME
  25. @enduml"
  26. (let ((org-plantuml-jar-path nil))
  27. (org-test-with-temp-text
  28. "#+name: variable_value
  29. : test_class
  30. #+header: :file tmp.puml
  31. #+header: :var CLASSNAME=variable_value
  32. #+begin_src plantuml
  33. class CLASSNAME
  34. #+end_src"
  35. (org-babel-next-src-block)
  36. (let ((src-block-info (cdr (org-babel-get-src-block-info))))
  37. (org-babel-plantuml-make-body
  38. (car src-block-info)
  39. (car (cdr src-block-info)))))))))
  40. (ert-deftest test-ob-plantuml/prologue ()
  41. "Test file output with prologue."
  42. (should
  43. (string=
  44. "@startuml
  45. skinparam classBackgroundColor #FF0000
  46. class test_class
  47. @enduml"
  48. (let ((org-plantuml-jar-path nil))
  49. (org-test-with-temp-text
  50. "#+header: :file tmp.puml
  51. #+header: :prologue skinparam classBackgroundColor #FF0000
  52. #+begin_src plantuml
  53. class test_class
  54. #+end_src"
  55. (org-babel-next-src-block)
  56. (let ((src-block-info (cdr (org-babel-get-src-block-info))))
  57. (org-babel-plantuml-make-body
  58. (car src-block-info)
  59. (car (cdr src-block-info)))))))))
  60. (provide 'test-ob-plantuml)
  61. ;;; test-ob-plantuml.el ends here