Skip to content

Commit

Permalink
Merge pull request #21 from bauglir/simplify-string-literal-tests
Browse files Browse the repository at this point in the history
Simplify 'string literal'/`Diagram` equivalence tests
  • Loading branch information
bauglir committed Jul 16, 2022
2 parents c8494c9 + b8a5890 commit 9e1d040
Showing 1 changed file with 22 additions and 10 deletions.
32 changes: 22 additions & 10 deletions test/kroki/string_literals_test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,28 @@ using Kroki: Diagram, @mermaid_str, @plantuml_str
# specifying diagrams.
#
# This is not an exhaustive test as these are dynamically generated. The
# basic functionality is only verified for key diagram types
string_literal_plantuml = plantuml"A -> B: C"
diagram_type_plantuml = Diagram(:PlantUML, "A -> B: C")
# The leading newlines make sure the alignment of the plain text
# representations is identical across both calling methods
@test "\n$string_literal_plantuml" == "\n$diagram_type_plantuml"

string_literal_mermaid = mermaid"graph TD; A --> B"
diagram_type_mermaid = Diagram(:mermaid, "graph TD; A --> B")
@test "$string_literal_mermaid" == "$diagram_type_mermaid"
# basic functionality is only verified for key diagram types.
#
# Note that the `specification`s and `type`s are compared directly. Comparing
# the resulting `Diagram`s directly compares their rendered versions which is
# a bit more finicky and duplicating test logic for `Base.show`
@testset "are equivalent to using `Diagram` constructors" begin
@testset "PlantUML" begin
string_literal = plantuml"A -> B: C"
diagram_constructor = Diagram(:plantuml, "A -> B: C")

@test string_literal.specification === diagram_constructor.specification
@test string_literal.type === diagram_constructor.type
end

@testset "Mermaid" begin
string_literal = mermaid"graph TD; A --> B"
diagram_constructor = Diagram(:mermaid, "graph TD; A --> B")

@test string_literal.specification === diagram_constructor.specification
@test string_literal.type === diagram_constructor.type
end
end

@testset "support interpolation" begin
# String macros do no support string interpolation out-of-the-box, this
Expand Down

0 comments on commit 9e1d040

Please sign in to comment.