<commit_before># frozen_string_literal: true

require 'spec_helper'

describe EasyPost::Report do
  describe '.create' do
    it 'creates a payment_log report' do
      report = described_class.create(
        start_date: Fixture.report_start_date,
        end_date: Fixture.report_end_date,
        type: 'payment_log',
      )

      expect(report).to be_an_instance_of(described_class)
      expect(report.id).to match('plrep')
    end

    it 'creates a refund report' do
      report = described_class.create(
        start_date: Fixture.report_start_date,
        end_date: Fixture.report_end_date,
        type: 'refund',
      )

      expect(report).to be_an_instance_of(described_class)
      expect(report.id).to match('refrep')
    end

    it 'creates a shipment report' do
      report = described_class.create(
        start_date: Fixture.report_start_date,
        end_date: Fixture.report_end_date,
        type: 'shipment',
      )

      expect(report).to be_an_instance_of(described_class)
      expect(report.id).to match('shprep')
    end

    it 'creates a shipment_invoice report' do
      report = described_class.create(
        start_date: Fixture.report_start_date,
        end_date: Fixture.report_end_date,
        type: 'shipment_invoice',
      )

      expect(report).to be_an_instance_of(described_class)
      expect(report.id).to match('shpinvrep')
    end

    it 'creates a tracker report' do
      report = described_class.create(
        start_date: Fixture.report_start_date,
        end_date: Fixture.report_end_date,
        type: 'tracker',
      )

      expect(report).to be_an_instance_of(described_class)
      expect(report.id).to match('trkrep')
    end

    it 'creates a report with custom columns' do
      report = described_class.create(
        start_date: Fixture.report_start_date,
        end_date: Fixture.report_end_date,
        type: 'shipment',
        columns: ['usps_zone'],
      )

      expect(report).to be_an_instance_of(described_class)
      # verify params by checking URL in cassette
      # can't do any more verification without downloading CSV
    end

    it 'creates a report with custom additional columns' do
      report = described_class.create(
        start_date: Fixture.report_start_date,
        end_date: Fixture.report_end_date,
        type: 'shipment',
        additional_columns: %w[from_name from_company],
      )

      expect(report).to be_an_instance_of(described_class)
      # verify params by checking URL in cassette
      # can't do any more verification without downloading CSV
    end
  end

  describe '.retrieve' do
    it 'retrieves a payment_log report' do
      report = described_class.create(
        start_date: Fixture.report_start_date,
        end_date: Fixture.report_end_date,
        type: 'payment_log',
      )

      retrieved_report = described_class.retrieve(report.id)<commit_msg>- Adjust unit test comment<commit_after># frozen_string_literal: true

require 'spec_helper'

describe EasyPost::Report do
  describe '.create' do
    it 'creates a payment_log report' do
      report = described_class.create(
        start_date: Fixture.report_start_date,
        end_date: Fixture.report_end_date,
        type: 'payment_log',
      )

      expect(report).to be_an_instance_of(described_class)
      expect(report.id).to match('plrep')
    end

    it 'creates a refund report' do
      report = described_class.create(
        start_date: Fixture.report_start_date,
        end_date: Fixture.report_end_date,
        type: 'refund',
      )

      expect(report).to be_an_instance_of(described_class)
      expect(report.id).to match('refrep')
    end

    it 'creates a shipment report' do
      report = described_class.create(
        start_date: Fixture.report_start_date,
        end_date: Fixture.report_end_date,
        type: 'shipment',
      )

      expect(report).to be_an_instance_of(described_class)
      expect(report.id).to match('shprep')
    end

    it 'creates a shipment_invoice report' do
      report = described_class.create(
        start_date: Fixture.report_start_date,
        end_date: Fixture.report_end_date,
        type: 'shipment_invoice',
      )

      expect(report).to be_an_instance_of(described_class)
      expect(report.id).to match('shpinvrep')
    end

    it 'creates a tracker report' do
      report = described_class.create(
        start_date: Fixture.report_start_date,
        end_date: Fixture.report_end_date,
        type: 'tracker',
      )

      expect(report).to be_an_instance_of(described_class)
      expect(report.id).to match('trkrep')
    end

    it 'creates a report with custom columns' do
      report = described_class.create(
        start_date: Fixture.report_start_date,
        end_date: Fixture.report_end_date,
        type: 'shipment',
        columns: ['usps_zone'],
      )

      # verify params by checking URL in cassette
      # can't do any more verification without downloading CSV
      expect(report).to be_an_instance_of(described_class)
    end

    it 'creates a report with custom additional columns' do
      report = described_class.create(
        start_date: Fixture.report_start_date,
        end_date: Fixture.report_end_date,
        type: 'shipment',
        additional_columns: %w[from_name from_company],
      )

      # verify params by checking URL in cassette
      # can't do any more verification without downloading CSV
      expect(report).to be_an_instance_of(described_class)
    end
  end

  describe '.retrieve' do
    it 'retrieves a payment_log report' do
      report = described_class.create(
        start_date: Fixture.report_start_date,
        end_date: Fixture.report_end_date,
        type: 'payment_log',
      )

      retrieved_report = described_class.retrieve(report.id)
{'fraction_non_alphanumeric': 0.08257510729613735, 'fraction_numerical': 0.0, 'mean_word_length': 2.848084544253633, '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': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3994934', 'n_tokens_mistral': 1838, 'n_tokens_neox': 1760, 'n_words': 403}