require "rails_helper"

module ExcelReports
  module VideoReports
    module DiscoveryProductionElementsLogs
      RSpec.describe ProductIntegrationSheet do
        let(:workbook) { instance_double(Axlsx::Workbook, :workbook) }

        it_behaves_like "a worksheet" do
          subject { described_class.new(workbook) }
        end

        describe "#title" do
          it "returns 'Product Integration'" do
            expect(described_class.new(workbook).title).to eq "Product Integration"
          end
        end

        describe "#format" do
          let(:sheet) { instance_double(Axlsx::Worksheet, :sheet) }

          before :each do
            allow(sheet).to receive(:column_widths)
            allow(sheet).to receive(:merge_cells)
          end

          it "sets sheet column widths to 15, 15, 15, 15, 15, 15, 15, 15, 15, 15" do
            expect(sheet).to receive(:column_widths).with(15, 15, 15, 15, 15, 15, 15, 15, 15, 15)

            described_class.new(workbook).format(sheet)
          end

          it "merges columns A4:A5 B4:B5 C4:C5 D4:D5 E4:E5 F4:F5 G4:G5 H4:H5 I4:J4" do
            %w(A4:A5 B4:B5 C4:C5 D4:D5 E4:E5 F4:F5 G4:G5 H4:H5 I4:J4).each do |cell|
              expect(sheet).to receive(:merge_cells).with(cell)
            end

            described_class.new(workbook).format(sheet)
          end
        end
      end
    end
  end
end
