<commit_before>require "test_helper"

describe Taxjar::Client do

  describe ".sales_tax" do
    before do
      @options = {
        amount: 10,
        shipping: 2,
        to_country: "US",
        to_state: "NJ",
        to_city: "Freehold",
        to_zip: "07728",
        from_country: "US",
        from_state: "NJ",
        from_city: "Ramsey",
        from_zip: "07446"
      }
    end

    describe "v1" do
      it "should return a SalesTax" do
        VCR.use_cassette("sales_tax_v1") do
          response = Taxjar::Client.new.sales_tax(@options)
          response.must_be :hash
        end
      end
    end

    describe "v2" do
      before do
        Taxjar.configure do |config|
          config.api_version = 2
          config.api_tier = 'standard'
        end
      end

      it "should return a SalesTax" do
        VCR.use_cassette("sales_tax_v2") do
          response = Taxjar::Client.new.sales_tax(@options)
          response.must_be :hash
        end
      end
    end
  end

  describe ".tax_rate" do
    before do
      @options = {
        zip: "07446",
        city: "Ramsey",
        country: "US"
      }
    end

    describe "v1" do
      it "should return a TaxRate" do
        VCR.use_cassette("tax_rate_v1") do
          response = Taxjar::Client.new.tax_rate(@options)
          response.must_be :hash
        end
      end
    end

    describe "v2" do
      before do<commit_msg>Reset version and tier for v1 tests<commit_after>require "test_helper"

describe Taxjar::Client do

  describe ".sales_tax" do
    before do
      @options = {
        amount: 10,
        shipping: 2,
        to_country: "US",
        to_state: "NJ",
        to_city: "Freehold",
        to_zip: "07728",
        from_country: "US",
        from_state: "NJ",
        from_city: "Ramsey",
        from_zip: "07446"
      }
    end

    describe "v1" do
      before do
        Taxjar.configure do |config|
          config.api_version = 1
          config.api_tier = nil
        end
      end

      it "should return a SalesTax" do
        VCR.use_cassette("sales_tax_v1") do
          response = Taxjar::Client.new.sales_tax(@options)
          response.must_be :hash
        end
      end
    end

    describe "v2" do
      before do
        Taxjar.configure do |config|
          config.api_version = 2
          config.api_tier = 'standard'
        end
      end

      it "should return a SalesTax" do
        VCR.use_cassette("sales_tax_v2") do
          response = Taxjar::Client.new.sales_tax(@options)
          response.must_be :hash
        end
      end
    end
  end

  describe ".tax_rate" do
    before do
      @options = {
        zip: "07446",
        city: "Ramsey",
        country: "US"
      }
    end

    describe "v1" do
      before do
        Taxjar.configure do |config|
          config.api_version = 1
          config.api_tier = nil
        end
      end

      it "should return a TaxRate" do
        VCR.use_cassette("tax_rate_v1") do
          response = Taxjar::Client.new.tax_rate(@options)
          response.must_be :hash
        end
      end
    end

    describe "v2" do
      before do
{'fraction_non_alphanumeric': 0.0901015228426396, 'fraction_numerical': 0.017449238578680203, 'mean_word_length': 1.6473551637279598, 'pattern_counts': {'":': 0, '<': 3, '<?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': '6929778', 'n_tokens_mistral': 1066, 'n_tokens_neox': 1003, 'n_words': 259}