From acec715a6ec8bdd5567e7ad99796a01db97adcfe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Schmelzer?= Date: Sat, 9 Mar 2019 07:47:03 +0100 Subject: [PATCH] indentation test for deployment diagram --- test/plantuml-indentation-deployment-test.el | 109 +++++++++++++++++++ test/plantuml-indentation-test.el | 23 ---- test/test-helper.el | 27 +++++ 3 files changed, 136 insertions(+), 23 deletions(-) create mode 100644 test/plantuml-indentation-deployment-test.el diff --git a/test/plantuml-indentation-deployment-test.el b/test/plantuml-indentation-deployment-test.el new file mode 100644 index 0000000..11b4637 --- /dev/null +++ b/test/plantuml-indentation-deployment-test.el @@ -0,0 +1,109 @@ +;;; plantuml-indentation-deployment-test.el --- PlantUML Mode indentation tests -*- lexical-binding: t; -*- + +;; Author: René Schmelzer +;; Maintainer: Carlo Sciolla (skuro) +;; URL: https://github.com/skuro/plantuml-mode + +;;; Commentary: + +;; Test indentation for class diagrams. +;; Most plantuml code examples are taken from www.plantuml.com + +;;; Code: + +(ert-deftest plantuml-test-indentation/deployment-diagram () + "Test correct indentation of plantuml deployment diagram elements." + (plantuml-test-indent-block + + " + artifact Foo1 { + folder Foo2 + } + + folder Foo3 { + artifact Foo4 + } + + frame Foo5 { + database Foo6 + } + + cloud vpc { + node ec2 { + stack stack + } + } + + node Foo1 { + cloud Foo2 + } + + cloud Foo3 { + frame Foo4 + } + + database Foo5 { + storage Foo6 + } + + storage Foo7 { + storage Foo8 + } + +skinparam rectangle { +roundCorner<> 25 +} + +rectangle \"Concept Model\" <> { +rectangle \"Example 1\" <> as ex1 +rectangle \"Another rectangle\" +} +" + " +artifact Foo1 { + folder Foo2 +} + +folder Foo3 { + artifact Foo4 +} + +frame Foo5 { + database Foo6 +} + +cloud vpc { + node ec2 { + stack stack + } +} + +node Foo1 { + cloud Foo2 +} + +cloud Foo3 { + frame Foo4 +} + +database Foo5 { + storage Foo6 +} + +storage Foo7 { + storage Foo8 +} + +skinparam rectangle { + roundCorner<> 25 +} + +rectangle \"Concept Model\" <> { + rectangle \"Example 1\" <> as ex1 + rectangle \"Another rectangle\" +} +")) + +(provide 'plantuml-indentation-deployment-test) + +;;; plantuml-indentation-deployment-test.el ends here diff --git a/test/plantuml-indentation-test.el b/test/plantuml-indentation-test.el index 7175d69..9a835fb 100644 --- a/test/plantuml-indentation-test.el +++ b/test/plantuml-indentation-test.el @@ -255,32 +255,9 @@ foofoo|" foofoo|")) -(defun plantuml-test-indent-block (before after) - "The common code for the block indentation tests. -BEFORE is the text block to be inserted into a temporary buffer. -AFTER is the expected text block after indentation. -The temporary buffer will be put into `plantuml-mode'. The whole buffer -will be indented with two spaces for each level of indentation. -Finally, the indented text in the buffer will be compared with AFTER." - - (with-temp-buffer - ;; fix the JAR location prior to mode initialization - ;; for some reason, plantuml-mode disregards the setq-local - (setq-local plantuml-jar-path plantuml-test-jar-path) - (plantuml-init-once) - - (insert before) - (goto-char (point-min)) - (plantuml-mode) - ;; use 2 spaces instead of one tab for indentation - (setq-local indent-tabs-mode nil) - (setq-local tab-width 2) - - (indent-region (point-min) (point-max)) - (should (equal (buffer-string) after)))) (ert-deftest plantuml-test-block-indentation/package-empty () "Test correct indentation of an empty package block." diff --git a/test/test-helper.el b/test/test-helper.el index 87c2e03..bbba7b4 100644 --- a/test/test-helper.el +++ b/test/test-helper.el @@ -39,6 +39,33 @@ "Make the preview output as S more readable in test output." (concat "\n" s)) +(defun plantuml-test-indent-block (before after) + "The common code for the block indentation tests. + +BEFORE is the text block to be inserted into a temporary buffer. +AFTER is the expected text block after indentation. + +The temporary buffer will be put into `plantuml-mode'. The whole buffer +will be indented with two spaces for each level of indentation. + +Finally, the indented text in the buffer will be compared with AFTER." + + (with-temp-buffer + ;; fix the JAR location prior to mode initialization + ;; for some reason, plantuml-mode disregards the setq-local + (setq-local plantuml-jar-path plantuml-test-jar-path) + (plantuml-init-once) + + (insert before) + (goto-char (point-min)) + (plantuml-mode) + ;; use 2 spaces instead of one tab for indentation + (setq-local indent-tabs-mode nil) + (setq-local tab-width 2) + + (indent-region (point-min) (point-max)) + (should (equal (buffer-string) after)))) + ;; enable code coverage (when (require 'undercover nil t) (undercover "plantuml-mode.el"))