require "rails_helper"

module ExcelReports
  module VideoReports
    module DiscoveryProductionElementsLogs
      RSpec.describe MediaRightsCertificationSheet 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 'Media Rights Certification'" do
            expect(described_class.new(workbook).title).to eq "Media Rights Certification"
          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 10, 20, 10, 10, 10, 10, 10, 10, 10, 10" do
            expect(sheet).to receive(:column_widths).with(10, 20, 10, 10, 10, 10, 10, 10, 10, 10)

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

          it "merges columns A1:J1 A2:J2 A3:J3 B4:J4 B5:J5 B6:J6 A8:J8 B9:J9 B10:J10 B11:J11 B12:J12 B13:J13 A14:J14 A15:J15" do
            %w(A1:J1 A2:J2 A3:J3 B4:J4 B5:J5 B6:J6 A8:J8 B9:J9 B10:J10 B11:J11 B12:J12 B13:J13 A14:J14 A15:J15).each do |cell|
              expect(sheet).to receive(:merge_cells).with(cell)
            end

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