<commit_before>require 'test_helper'

class FormHelperTest < EaselHelpers::ViewTestCase
  context "submit_button" do
    should "default with the correct structure" do
      show_view "<%= submit_button 'Create' %>" do
        assert_select "button.btn[type=submit]", 1
        assert_select "button span", 1
      end
    end
    
    should "allow adding additional classes" do
      show_view "<%= submit_button 'Create', 'adtl-class', :dumb %>" do
        assert_select "button.btn.adtl-class.dumb[type=submit]", 1
        assert_select "button span", 1
      end
    end
    
    should "handle additional attributes set" do
      show_view "<%= submit_button 'Create', :kls, :id => 'my-id', :type => 'image' %>" do
        assert_select "button.btn.kls#my-id[type=image]", 1
        assert_select "button span", 1
      end
    end
  end
  
  context "set" do
    should "default with the correct structure" do
      show_view "<% set do %>words<% end %>" do
        assert_select "div.text", {:count => 1, :text => "words"}
      end
    end
    
    should "allow adding/overriding classes" do
      show_view "<% set :checkbox do %>words<% end %>" do
        assert_select "div.checkbox", {:count => 1, :text => "words"}
      end
    end
    
    should "handle additional attributes set" do
      show_view "<% set :id => 'custom-id' do %>words<% end %>" do
        assert_select "div.text#custom-id", {:count => 1, :text => "words"}
      end
    end
    
    should "assign default class if width class is passed as the only class" do
      show_view "<% set :half do %>words<% end %>" do
        assert_select "div.text.col-12", {:count => 1, :text => "words"}
      end
    end
  end
end<commit_msg>Updated form helper tests<commit_after>require 'test_helper'

class FormHelperTest < EaselHelpers::ViewTestCase
  context "submit_button" do
    should "default with the correct structure" do
      show_view "<%= submit_button 'Create' %>" do
        assert_select "button.btn[type=submit]", 1 do
          assert_select "span", "Create"
        end
      end
    end
    
    should "allow adding additional classes" do
      show_view "<%= submit_button 'Create', 'adtl-class', :dumb %>" do
        assert_select "button.btn.adtl-class.dumb[type=submit]", 1 do
          assert_select "span", "Create"
        end
      end
    end
    
    should "handle additional attributes set" do
      show_view "<%= submit_button 'Create', :kls, :id => 'my-id', :type => 'image' %>" do
        assert_select "button.btn.kls#my-id[type=image]", 1 do
          assert_select "span", "Create"
        end
      end
    end
  end
  
  context "set" do
    should "default with the correct structure" do
      show_view "<% set do %>words<% end %>" do
        assert_select "div.text", {:count => 1, :text => "words"}
      end
    end
    
    should "allow adding/overriding classes" do
      show_view "<% set :checkbox do %>words<% end %>" do
        assert_select "div.checkbox", {:count => 1, :text => "words"}
      end
    end
    
    should "handle additional attributes set" do
      show_view "<% set :id => 'custom-id' do %>words<% end %>" do
        assert_select "div.text#custom-id", {:count => 1, :text => "words"}
      end
    end
    
    should "assign default class if width class is passed as the only class" do
      show_view "<% set :half do %>words<% end %>" do
        assert_select "div.text.col-12", {:count => 1, :text => "words"}
      end
    end
  end
  
  context "fieldset" do
    should "default with the correct structure" do
      show_view "<% fieldset do %>words<% end %>" do
        assert_select "fieldset", {:count => 1, :text => "words"}
      end
    end
    
    should "assign the first argument as the legend if it is a string" do
      show_view "<% fieldset 'User Information' do %>words<% end %>" do
        assert_select "fieldset", {:count => 1, :text => /words/} do
          assert_select "h3.legend", {:count => 1, :text => "User Information"}
        end
      end
    end
    
    should "allow adding fieldset classes" do
      show_view "<% fieldset :hform, 'col-last' do %>words<% end %>" do
        assert_select "fieldset.hform.col-last", {:count => 1, :text => "words"}
      end
    end
    
    should "allow adding fieldset classes and a legend" do
      show_view "<% fieldset 'User Information', :hform, 'col-last' do %>words<% end %>" do
        assert_select "fieldset.hform.col-last", {:count => 1, :text => /words/} do
          assert_select "h3.legend", {:count => 1, :text => "User Information"}
        end
      end
    end
    
    should "allow assignment of legend attributes" do
      show_view "<% fieldset 'User Information', :hform, :legend => {:class => 'lgnd', :id => 'legend-id'} do %>words<% end %>" do
        assert_select "fieldset.hform", {:count => 1, :text => /words/} do
          assert_select "h3.legend.lgnd#legend-id", {:count => 1, :text => "User Information"}
        end
      end
    end
    
    should "allow assignment of fieldset attributes" do
      show_view "<% fieldset 'User Information', :hform, :id => 'my-fieldset' do %>words<% end %>" do
        assert_select "fieldset.hform#my-fieldset", {:count => 1, :text => /words/} do
          assert_select "h3.legend", {:count => 1, :text => "User Information"}
        end
      end
    end
    
    
    
  end
end
{'fraction_non_alphanumeric': 0.13589886596021566, 'fraction_numerical': 0.006506785647889942, 'mean_word_length': 2.5255570117955437, 'pattern_counts': {'":': 0, '<': 39, '<?xml version=': 0, '>': 83, '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': '4299671', 'n_tokens_mistral': 1729, 'n_tokens_neox': 1641, 'n_words': 542}