Sha256: c77f7bc8545d90856227ba50f54de1806baff07c9311a80915c6a355f28de17d

Contents?: true

Size: 1.5 KB

Versions: 1

Compression:

Stored size: 1.5 KB

Contents

# frozen_string_literal: true

# This file is part of Alexandria.
#
# See the file README.md for authorship and licensing information.

require_relative "../../spec_helper"

describe Alexandria::UI::SmartLibraryPropertiesDialog do
  let(:properties_dialog) do
    parent = Gtk::Window.new :toplevel
    loader = Alexandria::LibraryStore.new(TESTDIR)
    smart_library = Alexandria::SmartLibrary.new("Foo", [], :all, loader)
    described_class.new parent, smart_library
  end
  let(:gtk_dialog) { properties_dialog.dialog }

  describe "#acquire" do
    it "works when response is cancel" do
      allow(gtk_dialog).to receive(:run).and_return(Gtk::ResponseType::CANCEL)
      expect { properties_dialog.acquire }.not_to raise_error
    end

    it "works when response is ok" do
      allow(gtk_dialog).to receive(:run).and_return(Gtk::ResponseType::OK)
      expect { properties_dialog.acquire }.not_to raise_error
    end
  end

  describe "#handle_date_icon_press" do
    let(:date_entry) do
      rule_boxes = properties_dialog.handle_add_rule_clicked
      rule_box = rule_boxes.first
      rule_box.children[3]
    end

    before do
      gtk_dialog.show_all
    end

    it "pops up the calendar widget" do
      properties_dialog.handle_date_icon_press(date_entry,
                                               Gtk::EntryIconPosition::PRIMARY,
                                               nil)
      popup = properties_dialog.instance_variable_get(:@calendar_popup)
      expect(popup).to be_visible
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
alexandria-book-collection-manager-0.7.10 spec/alexandria/ui/smart_library_properties_dialog_spec.rb