require "rails_helper"

module ExcelReports
  module VideoReports
    module NatGeoLegalBinderLogs
      RSpec.describe LegalBinderChecklistSheet, type: :model do
        let(:video) { build(:video, number: 1, name: "My Episode") }
        let(:workbook) { instance_double(Axlsx::Workbook, :workbook) }

        subject { described_class.new(workbook, [], video) }

        it_behaves_like "a worksheet"

        describe "#title" do
          it "returns the title of the sheet" do
            expect(subject.title).to eq "Legal Binder Checklist"
          end
        end

        describe "#fill_content" do
          it "adds content from the video" do
            sheet = instance_double(Axlsx::Worksheet, :sheet) 
            allow(sheet).to receive(:add_row)

            subject.fill_content(sheet)

            expect(sheet).to have_received(:add_row).with(["SERIES TITLE:", ""])
            expect(sheet).to have_received(:add_row).with(["EPISODE NUMBER:","1"])
            expect(sheet).to have_received(:add_row).with(["EPISODE TITLE:", "My Episode"])
          end
        end

        describe "#format" do
          it "sets column widths and merges cells" do
            sheet = instance_double(Axlsx::Worksheet, :sheet)
            allow(sheet).to receive(:column_widths)
            allow(sheet).to receive(:merge_cells)

            subject.format(sheet)

            expect(sheet).to have_received(:column_widths)
            expect(sheet).to have_received(:merge_cells).at_least(1).times
          end
        end

        describe "#style" do
          it "sets sheet style" do
            sheet = instance_double(Axlsx::Worksheet, :sheet)
            allow(sheet).to receive(:add_style)

            subject.style(sheet)

            expect(sheet).to have_received(:add_style).at_least(1).times
          end
        end
      end
    end
  end
end
