require 'minitest_helper'
require 'pre-commit/list_evaluator'
require 'plugins/pre_commit/configuration/providers/default'
require 'plugins/pre_commit/configuration/providers/git'
require 'plugins/pre_commit/checks/before_all'
require 'plugins/pre_commit/checks/console_log'

describe PreCommit::ListEvaluator do
  let :configuration do
    PreCommit::Configuration.new(
      PreCommit.pluginator,
      PreCommit::Configuration::Providers.new(nil, [
        PreCommit::Configuration::Providers::Default.new({}),
      ])
    )
  end

  subject do
    PreCommit::ListEvaluator.new(configuration)
  end

  it :list do
    subject.list.gsub(/\s+\n/,"\n").must_equal(<<-EXPECTED)
Available providers: default(0)
Available checks   : #{available_checks}
Default   checks   :
Enabled   checks   :
Evaluated checks   :
Default   warnings :
Enabled   warnings :
Evaluated warnings :
EXPECTED
  end

  it "plugins have includes" do
    subject.send(:format_plugin, "ruby", "6", configuration.pluginator.find_check(:ruby)).must_equal([
      "  ruby : Plugins common for ruby.",
      "       - includes: pry local",
    ])
  end
  it "plugins have excludes" do
    subject.send(:format_plugin, "rubocop", "7", configuration.pluginator.find_check(:rubocop)).must_equal([
      "rubocop : Runs rubocop to detect errors.",
      "        - excludes: ruby_symbol_hashrocket",
    ])
  end
end
