require "rails_helper"

module ExcelReports
  module GraphicReports
    module DiscoveryGfxCueLists
      RSpec.describe TextedElementsSheet 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 'Texted Elements List'" do
            expect(described_class.new(workbook).title).to eq "Texted Elements List"
          end
        end

        describe "#format" do
          it "sets sheet column widths to 60, 20, 20" do
            sheet = instance_double(Axlsx::Worksheet, :sheet)
            expect(sheet).to receive(:column_widths).with(60, 20, 20)

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

        describe "#style" do
          it "sets sheet style" do
            sheet = instance_double(Axlsx::Worksheet, :sheet)
            expect(sheet).to receive(:add_style).with("A1", { b: true }, { sz: 12 })
            expect(sheet).to receive(:add_style).with(
              "A9:D9",
              {
                bg_color: "97CBFC",
                b: true,
                border: { :style => :thick, :color => "000000" },
                alignment: { :horizontal => :center, :vertical => :center, :wrap_text => true },
                sz: 8,
              }
            )
            expect(sheet).to receive(:add_style).with("A3:A7",
                                                      {
              bg_color: "97CBFC",
              b: true,
              border: { :style => :thick, :color => "000000" },
              alignment: { :horizontal => :center, :wrap_text => true },
              sz: 12,
            }
                                                     )
            expect(sheet).to receive(:add_style).with(
              "B3:B7",
              {
                border: { :style => :thick, :color => "000000" },
                alignment: { :wrap_text => true, :horizontal => :left },
                sz: 10,
              }
            )
            expect(sheet).to receive(:add_style).at_least(1).with("A10:D11",
                                                                  {
              border: { style: :thick, color: "000000" },
              alignment: { wrap_text: true },
              sz: 10
            }
                                                                 )

            described_class.new(workbook, ["data1", "data2"]).style(sheet)
          end
        end
      end
    end
  end
end
