<commit_before># coding: utf-8

require "test_helper"

class Admin::SidebarHelperTest < ActiveSupport::TestCase

  include Admin::SidebarHelper

  include ActionView::Helpers::UrlHelper
  include ActionView::Helpers::TagHelper
  include ActionView::Helpers::FormTagHelper

  def render(*args); args; end
  def link_to(*args); args; end

  setup do
    default_url_options[:host] = 'test.host'
  end

  should "test_actions"

  should "test_export" do
    params = { :controller => '/admin/posts', :action => 'index' }

    output = export(Post , params)
    expected = [["Export as CSV", { :action => "index", :format => "csv", :controller => "/admin/posts" }],
                ["Export as XML", { :action => "index", :format => "xml", :controller => "/admin/posts" }]]

    assert_equal expected, output
  end

  should_eventually "test_build_typus_list_with_empty_content_and_empty_header" do
    output = build_typus_list([], :header => nil)
    assert output.empty?
  end

  should_eventually "test_build_typus_list_with_content_and_header" do
    output = build_typus_list(['item1', 'item2'], :header => "Chunky Bacon")
    assert !output.empty?

    expected = [ "admin/helpers/list", { :header=>"Chunky bacon",
                                         :options => { :header => "Chunky Bacon" },
                                         :items => [ "item1", "item2" ] } ]

    assert_equal expected, output
  end

  should_eventually "test_build_typus_list_with_content_without_header" do
    output = build_typus_list(['item1', 'item2'])
    expected = [ "admin/helpers/list", { :header => nil,
                                         :options => {},
                                         :items=>["item1", "item2"] } ]
    assert_equal expected, output
  end

  should_eventually "test_search" do<commit_msg>This is no longer used<commit_after># coding: utf-8

require "test_helper"

class Admin::SidebarHelperTest < ActiveSupport::TestCase

  include Admin::SidebarHelper

  include ActionView::Helpers::UrlHelper
  include ActionView::Helpers::TagHelper
  include ActionView::Helpers::FormTagHelper

  def render(*args); args; end
  def link_to(*args); args; end

  setup do
    default_url_options[:host] = 'test.host'
  end

  should "test_actions"

  should "test_export" do
    params = { :controller => '/admin/posts', :action => 'index' }

    output = export(Post , params)
    expected = [["Export as CSV", { :action => "index", :format => "csv", :controller => "/admin/posts" }],
                ["Export as XML", { :action => "index", :format => "xml", :controller => "/admin/posts" }]]

    assert_equal expected, output
  end

  should_eventually "test_search" do
{'fraction_non_alphanumeric': 0.13722573447378208, 'fraction_numerical': 0.003718854592785422, 'mean_word_length': 3.2163009404388716, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 28, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2967058', 'n_tokens_mistral': 805, 'n_tokens_neox': 786, 'n_words': 192}