<commit_before>require "action_view/test_case"
require "html/document"
require "expected_elements"

class JudgeFormBuilderTest < ActionView::TestCase

  include ExpectedElements

  def test_text_field
    assert_dom_equal expected_text_field, builder.text_field(:name, :validate => true)
  end

  def test_text_area
    assert_dom_equal expected_text_area, builder.text_area(:bio, :validate => true)
  end

  def test_password_field
    assert_dom_equal expected_password_field, builder.password_field(:password, :validate => true)
  end

  def test_check_box
    assert_dom_equal expected_check_box, builder.password_field(:accepted, :validate => true)
  end

  def test_radio_button
    assert_dom_equal expected_radio_button, builder.radio_button(:gender, "female", :validate => true)
  end

  def test_select
    assert_dom_equal expected_select, builder.select(:country, [["US", "US"], ["GB", "GB"]], :validate => true)
  end

  def test_collection_select
    assert_dom_equal expected_collection_select, builder.collection_select(:team_id, FactoryGirl.create_list(:team, 5), :id, :name, :validate => true)
  end

  def test_grouped_collection_select
    assert_dom_equal expected_grouped_collection_select, builder.grouped_collection_select(:discipline_id, categories, :sports, :name, :id, :name, :validate => true)
  end

  def test_date_select
    assert_dom_equal expected_date_select, builder.date_select(:dob, :validate => true, :minute_step => 30)
  end

  def test_datetime_select
    assert_dom_equal expected_datetime_select, builder.datetime_select(:dob, :validate => true, :minute_step => 30)
  end

  def test_time_select
    assert_dom_equal expected_time_select, builder.time_select(:dob, :validate => true, :minute_step => 30)
  end

  def test_time_zone_select
    assert_dom_equal expected_time_zone_select, builder.time_zone_select(:time_zone, ActiveSupport::TimeZone.us_zones, :include_blank => true, :validate => true)
  end

  def builder
    Judge::FormBuilder.new(:user, FactoryGirl.build(:user), self, {}, nil)
  end

  def categories<commit_msg>Make time_zone_select test a general assertion instead of asserting DOM equal (time zones are variable)<commit_after>require "action_view/test_case"
require "html/document"
require "expected_elements"

class JudgeFormBuilderTest < ActionView::TestCase

  include ExpectedElements

  def test_text_field
    assert_dom_equal expected_text_field, builder.text_field(:name, :validate => true)
  end

  def test_text_area
    assert_dom_equal expected_text_area, builder.text_area(:bio, :validate => true)
  end

  def test_password_field
    assert_dom_equal expected_password_field, builder.password_field(:password, :validate => true)
  end

  def test_check_box
    assert_dom_equal expected_check_box, builder.password_field(:accepted, :validate => true)
  end

  def test_radio_button
    assert_dom_equal expected_radio_button, builder.radio_button(:gender, "female", :validate => true)
  end

  def test_select
    assert_dom_equal expected_select, builder.select(:country, [["US", "US"], ["GB", "GB"]], :validate => true)
  end

  def test_collection_select
    assert_dom_equal expected_collection_select, builder.collection_select(:team_id, FactoryGirl.create_list(:team, 5), :id, :name, :validate => true)
  end

  def test_grouped_collection_select
    assert_dom_equal expected_grouped_collection_select, builder.grouped_collection_select(:discipline_id, categories, :sports, :name, :id, :name, :validate => true)
  end

  def test_date_select
    assert_dom_equal expected_date_select, builder.date_select(:dob, :validate => true, :minute_step => 30)
  end

  def test_datetime_select
    assert_dom_equal expected_datetime_select, builder.datetime_select(:dob, :validate => true, :minute_step => 30)
  end

  def test_time_select
    assert_dom_equal expected_time_select, builder.time_select(:dob, :validate => true, :minute_step => 30)
  end

  def test_time_zone_select
    assert builder.time_zone_select(:time_zone, ActiveSupport::TimeZone.us_zones, :include_blank => true, :validate => true), "time zone select not present"
  end

  def builder
    Judge::FormBuilder.new(:user, FactoryGirl.build(:user), self, {}, nil)
  end

  def categories
{'fraction_non_alphanumeric': 0.09440641963653529, 'fraction_numerical': 0.003304224687278735, 'mean_word_length': 5.891056910569105, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 35, 'https://': 0, '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': '4119522', 'n_tokens_mistral': 1342, 'n_tokens_neox': 1286, 'n_words': 295}