<commit_before>require_relative '../test_helper'
require 'trackler/problem'

class ProblemTest < Minitest::Test
  def test_existing_problem
    problem = Trackler::Problem.new('hello-world', FIXTURE_PATH)

    assert problem.exists?, "hello world files not found in the metadata dir"
    assert_equal 'hello-world', problem.slug
    assert_equal 'Oh, hello.', problem.blurb
    assert_equal "* hello\n* hello again\n", problem.description
    assert_equal 'https://github.com/exercism/x-common/blob/master/exercises/hello-world/metadata.yml', problem.yaml_url
    assert_equal 'https://github.com/exercism/x-common/blob/master/exercises/hello-world/description.md', problem.md_url

    assert_equal "## Source\n\nThe internet. [http://example.com](http://example.com)", problem.source_markdown
    assert_equal 'The internet.', problem.source
    assert_equal 'http://example.com', problem.source_url
  end

  def test_problem_name
    problem = Trackler::Problem.new('hello-world', FIXTURE_PATH)
    assert_equal 'Hello World', problem.name
  end

  def test_json_url
    problem = Trackler::Problem.new('mango', FIXTURE_PATH)
    assert_equal "https://github.com/exercism/x-common/blob/master/exercises/mango/canonical-data.json", problem.json_url
  end

  def test_json_url_missing
    problem = Trackler::Problem.new('banana', FIXTURE_PATH)
    assert_equal nil, problem.json_url
  end

  def test_default_location
    problem = Trackler::Problem.new('mango', FIXTURE_PATH)
    assert_equal "## Source\n\nThe mango. [http://example.com](http://example.com)", problem.source_markdown
  end

  def test_source_markdown_no_source
    # in deprecated location<commit_msg>Rename misleadingly named test method.<commit_after>require_relative '../test_helper'
require 'trackler/problem'

class ProblemTest < Minitest::Test
  def test_existing_problem
    problem = Trackler::Problem.new('hello-world', FIXTURE_PATH)

    assert problem.exists?, "hello world files not found in the metadata dir"
    assert_equal 'hello-world', problem.slug
    assert_equal 'Oh, hello.', problem.blurb
    assert_equal "* hello\n* hello again\n", problem.description
    assert_equal 'https://github.com/exercism/x-common/blob/master/exercises/hello-world/metadata.yml', problem.yaml_url
    assert_equal 'https://github.com/exercism/x-common/blob/master/exercises/hello-world/description.md', problem.md_url

    assert_equal "## Source\n\nThe internet. [http://example.com](http://example.com)", problem.source_markdown
    assert_equal 'The internet.', problem.source
    assert_equal 'http://example.com', problem.source_url
  end

  def test_problem_name
    problem = Trackler::Problem.new('hello-world', FIXTURE_PATH)
    assert_equal 'Hello World', problem.name
  end

  def test_json_url
    problem = Trackler::Problem.new('mango', FIXTURE_PATH)
    assert_equal "https://github.com/exercism/x-common/blob/master/exercises/mango/canonical-data.json", problem.json_url
  end

  def test_json_url_missing
    problem = Trackler::Problem.new('banana', FIXTURE_PATH)
    assert_equal nil, problem.json_url
  end

  def test_default_location
    problem = Trackler::Problem.new('mango', FIXTURE_PATH)
    assert_equal "## Source\n\nThe mango. [http://example.com](http://example.com)", problem.source_markdown
  end

  def test_source_markdown_in_depricated_location
{'fraction_non_alphanumeric': 0.11996418979409132, 'fraction_numerical': 0.0, 'mean_word_length': 4.568106312292358, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '945076', 'n_tokens_mistral': 1092, 'n_tokens_neox': 1045, 'n_words': 196}