Sha256: 0ef1bb599eb3dc3817f0ae37d0a91f17d3a9f8f3905dfba90625837681486395

Contents?: true

Size: 1.67 KB

Versions: 4

Compression:

Stored size: 1.67 KB

Contents

# frozen_string_literal: true

require "test_helper"

class MermaidErdMarkdown::MarkdownDocumentTest < Minitest::Test
  def test_generate
    markdown = MermaidErdMarkdown::MarkdownDocument.create do
      add(header("Header"))
      add(subheader("Subheader"))
      add(list_item("List item"))
      add(link("Link", "https://example.com"))
      add("")
    end

    assert_equal <<~MARKDOWN, markdown
      # Header

      ## Subheader

      - List item
      [Link](https://example.com)
    MARKDOWN
  end

  def test_erd
    model = {
      TableName: "table",
      ModelName: "Table",
      IsModelExist: true,
      Columns: [{
        name: "name",
        type: "type",
        key: "key",
        comment: "comment"
      }]
    }
    relation = {
      LeftModelName: "left_model",
      LeftValue: "left_value",
      Line: "--",
      RightValue: "right_value",
      RightModelName: "right_model",
      Comment: "comment"
    }

    markdown = MermaidErdMarkdown::MarkdownDocument.create do
      erd do
        add(
          erd_table(model[:TableName], model[:ModelName]) do
            erd_table_column(model[:Columns].first)
          end
        )
        add(
          erd_relation(relation)
        )
      end
      add("")
    end

    assert_equal <<~MARKDOWN, markdown
      ```mermaid
      erDiagram
          %% --------------------------------------------------------
          %% Entity-Relationship Diagram
          %% --------------------------------------------------------

          %% table name: table
          Table{
              type name key
          }

          left_model left_value--right_value right_model : "comment"
      ```
    MARKDOWN
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rails-mermaid_erd_markdown-0.4.0 test/test_rails/rails-mermaid_erd_markdown/test_markdown_document.rb
rails-mermaid_erd_markdown-0.3.2 test/test_rails/rails-mermaid_erd_markdown/test_markdown_document.rb
rails-mermaid_erd_markdown-0.3.1 test/test_rails/rails-mermaid_erd_markdown/test_markdown_document.rb
rails-mermaid_erd_markdown-0.3.0 test/test_rails/rails-mermaid_erd_markdown/test_markdown_document.rb