<commit_before>require 'rails_helper'

RSpec.describe BiodiversityReportsHelper, type: :helper do

  let(:soil_sample) { build(:soil_sample) }
  let(:empty_soil_sample) { double }
  before { allow(empty_soil_sample).to receive(:has_temperature_or_ph_level?).and_return(false) }

  describe "#link_to_toggle_soil_sample_fields" do
    context "when the soil sample has attribute values" do
      it "returns an Omit link" do
        expect(helper.link_to_toggle_soil_sample_fields(soil_sample)).to match "<a.*>Omit soil sample</a>"
      end
    end
    context "when the soil sample does not have attribute values" do
      it "returns an Add link" do
        expect(helper.link_to_toggle_soil_sample_fields(empty_soil_sample)).to match "<a.*>Add soil sample</a>"
      end
    end
    context "when the soil sample is nil" do
      it "returns nil" do
        expect(helper.link_to_toggle_soil_sample_fields(nil)).to be_nil
      end
    end
  end

  describe "#show_css_class" do
    context "when the soil sample has attribute values" do
      it "returns 'in'" do
        expect(helper.show_css_class(soil_sample)).to eq('in')
      end
    end
    context "when the soil sample does not have attribute values" do
      it "returns false" do
        expect(helper.show_css_class(empty_soil_sample)).to be(false)
      end
    end
    context "when the soil sample is nil" do
      it "returns nil" do
        expect(helper.show_css_class(nil)).to be_nil
      end
    end
  end

end<commit_msg>WIP: Begin testing of link_to_add_fields. See https://github.com/osu-cascades/ecotone-web/issues/73 References #73.<commit_after>require 'rails_helper'

RSpec.describe BiodiversityReportsHelper, type: :helper do

  let(:soil_sample) { build(:soil_sample) }
  let(:empty_soil_sample) { double }
  before { allow(empty_soil_sample).to receive(:has_temperature_or_ph_level?).and_return(false) }

  describe "#link_to_toggle_soil_sample_fields" do
    context "when the soil sample has attribute values" do
      it "returns an Omit link" do
        expect(helper.link_to_toggle_soil_sample_fields(soil_sample)).to match "<a.*>Omit soil sample</a>"
      end
    end
    context "when the soil sample does not have attribute values" do
      it "returns an Add link" do
        expect(helper.link_to_toggle_soil_sample_fields(empty_soil_sample)).to match "<a.*>Add soil sample</a>"
      end
    end
    context "when the soil sample is nil" do
      it "returns nil" do
        expect(helper.link_to_toggle_soil_sample_fields(nil)).to be_nil
      end
    end
  end

  describe "#show_css_class" do
    context "when the soil sample has attribute values" do
      it "returns 'in'" do
        expect(helper.show_css_class(soil_sample)).to eq('in')
      end
    end
    context "when the soil sample does not have attribute values" do
      it "returns false" do
        expect(helper.show_css_class(empty_soil_sample)).to be(false)
      end
    end
    context "when the soil sample is nil" do
      it "returns nil" do
        expect(helper.show_css_class(nil)).to be_nil
      end
    end
  end

  # link_to_add_fields 'Add plant sample', form, :plant_samples
  describe "#link_to_add_fields" do
    pending
    # subject(:link) { link_to_add_fields('Fake', "TODO: BiodiversityReport form builder object", :soil_sample) }
    # it { is_expected.to match /<a href="#" class="add_fields" data-id=".*" data-fields=".*">Fake<\/a>/ }
  end

end
{'fraction_non_alphanumeric': 0.09365910413030831, 'fraction_numerical': 0.0011634671320535194, 'mean_word_length': 3.4203084832904884, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 1, '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': '2644277', 'n_tokens_mistral': 1117, 'n_tokens_neox': 1095, 'n_words': 308}