Sha256: 038ff6ded66934289a6461ddd2beb2478e62d6a95c111651dc101068ded54ca9

Contents?: true

Size: 1.34 KB

Versions: 3

Compression:

Stored size: 1.34 KB

Contents

# frozen_string_literal: true

require_relative "../../mock_data/models"
require "test_helper"

class MermaidErdMarkdown::GeneratorTest < Minitest::Test
  include MockData::Models

  def test_index_markdown
    markdown_file_path = File.expand_path(
      "../../example_output/mock_ERD_index.md", __dir__
    )
    mock_markdown = File.read(markdown_file_path)

    files = {
      "User" => "User.md",
      "Profile" => "Profile.md",
      "Article" => "Article.md",
      "Comment" => "Comment.md"
    }

    result = MermaidErdMarkdown::Generator.new.index_markdown(files)

    assert_equal mock_markdown, result
  end

  def test_model_markdown
    markdown_file_path = File.expand_path(
      "../../example_output/mock_ERD_model.md", __dir__
    )
    mock_markdown = File.read(markdown_file_path)

    source = {
      Models: [user_model, article_model, profile_model],
      Relations: [article_relation, profile_relation]
    }

    result = MermaidErdMarkdown::Generator.new.model_markdown(source)

    assert_equal mock_markdown, result
  end

  def test_mermaid_markdown
    markdown_file_path =
      File.expand_path("../../example_output/mock_ERD.md", __dir__)
    mock_markdown = File.read(markdown_file_path)

    result = MermaidErdMarkdown::Generator.new.mermaid_markdown(
      stubbed_model_data
    )

    assert_equal mock_markdown, result
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

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