Sha256: 0399d27c15fce01254fb7dd01d9e533ffef20ec9a2caec751b5fdc485a54c3af

Contents?: true

Size: 1.47 KB

Versions: 2

Compression:

Stored size: 1.47 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::UIManager do
  let(:main_app) { instance_double(Alexandria::UI::MainApp) }

  it "works" do
    described_class.new main_app
  end

  describe "#on_new" do
    it "works" do
      ui = described_class.new main_app
      libraries = ui.instance_variable_get("@libraries")
      libraries_count = libraries.all_libraries.count
      ui.on_new
      expect(libraries.all_libraries.count).to eq libraries_count + 1
    end
  end

  describe "#on_books_selection_changed" do
    let(:lib_version) { File.join(LIBDIR, "0.6.2") }
    let(:ui) { described_class.new main_app }
    let(:libraries) { ui.instance_variable_get("@libraries") }
    let(:regular_library) { libraries.all_regular_libraries.last }

    before do
      FileUtils.cp_r(lib_version, TESTDIR)
    end

    it "works when single book is selected" do
      ui.select_a_library regular_library

      # FIXME: This is needed because right now UIManager#refresh_books doesn't
      # work without Gtk loop.
      regular_library.each { |book| ui.append_book book }
      ui.iconview.unfreeze
      expect(ui.model.iter_n_children).to eq regular_library.count

      # This triggers the #on_books_selection_changed callback
      ui.select_a_book regular_library.first

      expect(ui.iconview.selected_items).not_to be_empty
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
alexandria-book-collection-manager-0.7.7 spec/alexandria/ui/ui_manager_spec.rb
alexandria-book-collection-manager-0.7.6 spec/alexandria/ui/ui_manager_spec.rb