require_relative "../../features/support/math_helper"

RSpec.describe "MathHelper" do
  let(:class_instance) { (Class.new { include MathHelper }).new }

  describe "#quarter_start_for_period" do
    it "returns the correct start for period 196" do
      expect(class_instance.quarter_start_for_period(196)).to eq 196
    end

    it "returns the correct start for period 197" do
      expect(class_instance.quarter_start_for_period(197)).to eq 196
    end

    it "returns the correct start for period 198" do
      expect(class_instance.quarter_start_for_period(198)).to eq 196
    end
  end

  describe "#quarter_end_for_period" do
    it "returns the correct end for period 196" do
      expect(class_instance.quarter_end_for_period(196)).to eq 198
    end

    it "returns the correct end for period 197" do
      expect(class_instance.quarter_end_for_period(197)).to eq 198
    end

    it "returns the correct end for period 198" do
      expect(class_instance.quarter_end_for_period(198)).to eq 198
    end
  end

  describe "#period_to_quarter_string" do
    it "returns the correct quarter for period 192" do
      expect(class_instance.period_to_quarter_string(192)).to eq "Q4 2014"
    end

    it "returns the correct quarter for period 195" do
      expect(class_instance.period_to_quarter_string(195)).to eq "Q1 2015"
    end

    it "returns the correct quarter for period 196" do
      expect(class_instance.period_to_quarter_string(196)).to eq "Q2 2015"
    end

    it "returns the correct quarter for period 197" do
      expect(class_instance.period_to_quarter_string(197)).to eq "Q2 2015"
    end

    it "returns the correct quarter for period 198" do
      expect(class_instance.period_to_quarter_string(198)).to eq "Q2 2015"
    end
  end

  describe "#period_to_month_string" do
    it "returns the correct quarter for period 192" do
      expect(class_instance.period_to_month_string(192)).to eq "Dec 2014"
    end

    it "returns the correct quarter for period 195" do
      expect(class_instance.period_to_month_string(195)).to eq "Mar 2015"
    end

    it "returns the correct quarter for period 196" do
      expect(class_instance.period_to_month_string(196)).to eq "Apr 2015"
    end

    it "returns the correct quarter for period 197" do
      expect(class_instance.period_to_month_string(197)).to eq "May 2015"
    end

    it "returns the correct quarter for period 198" do
      expect(class_instance.period_to_month_string(198)).to eq "Jun 2015"
    end
  end
end
