<commit_before># frozen_string_literal: true

require "test_helper"

class GobiertoBudgets::BudgetLineDescendantsControllerTest < GobiertoControllerTest
  def site
    @site ||= sites(:madrid)
  end

  def test_index
    with_current_site(site) do
      get gobierto_budgets_budget_line_descendants_path(year: 2017, kind: GobiertoBudgets::BudgetLine::INCOME, area_name: GobiertoBudgets::EconomicArea.area_name, parent_code: '1'), as: :json
      assert_response :success
      response_data = JSON.parse(response.body)
      assert_equal 1, response_data.length
      assert_equal "Impuesto sobre la renta", response_data.first["name"]
    end
  end
end<commit_msg>Add test to check js response of descendants controller<commit_after># frozen_string_literal: true

require "test_helper"

class GobiertoBudgets::BudgetLineDescendantsControllerTest < GobiertoControllerTest
  def site
    @site ||= sites(:madrid)
  end

  def test_index_json
    with_current_site(site) do
      get gobierto_budgets_budget_line_descendants_path(year: 2017, kind: GobiertoBudgets::BudgetLine::INCOME, area_name: GobiertoBudgets::EconomicArea.area_name, parent_code: '1'), as: :json
      assert_response :success
      response_data = JSON.parse(response.body)
      assert_equal 1, response_data.length
      assert_equal "Impuesto sobre la renta", response_data.first["name"]
    end
  end

  def test_index_js
    with_current_site(site) do
      get gobierto_budgets_budget_line_descendants_path(year: 2017, kind: GobiertoBudgets::BudgetLine::INCOME, area_name: GobiertoBudgets::EconomicArea.area_name, parent_code: '2'), xhr: true#  as: :js
      assert_response :success
      assert_equal 2, response.body.scan(/(?=Impuesto sobre el Valor Añadido)/).count
    end
  end
end
{'fraction_non_alphanumeric': 0.0851305334846765, 'fraction_numerical': 0.01021566401816118, 'mean_word_length': 5.229681978798586, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '3959219', 'n_tokens_mistral': 611, 'n_tokens_neox': 573, 'n_words': 123}