Skip to content

Commit

Permalink
Added network proposal tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
teclator committed Jan 20, 2017
1 parent 76705e7 commit 1039838
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 2 deletions.
2 changes: 0 additions & 2 deletions src/lib/network/clients/network_proposal.rb
Expand Up @@ -14,8 +14,6 @@ def initialize
textdomain "installation"
end

protected

def description
{
"rich_text_title" => _("Network Configuration"),
Expand Down
64 changes: 64 additions & 0 deletions test/network_proposal_test.rb
@@ -0,0 +1,64 @@
require_relative "test_helper"

require "network/clients/network_proposal"

class DummyLanItems
def summary(params)
params == "one_line" ? "one line summary" : "rich_text_summary"
end
end

class DummyLan
def Summary(_)
["rich_text_summary"]
end
end

describe Yast::NetworkProposal do
subject { Yast::NetworkProposal.new }

let(:lan_items_mock) { DummyLanItems.new }
let(:lan_mock) { DummyLan.new }

before do
stub_const("Yast::LanItems", lan_items_mock)
stub_const("Yast::Lan", lan_mock)
end

describe "#description" do
it "returns a map with id, menu_title and rich_text_title " do
expect(subject.description).to include("id", "menu_title", "rich_text_title")
end
end

describe "#make_proposal" do
it "returns a map with 'label_proposal' as an array with one line summary'" do
expect(subject.make_proposal({})["label_proposal"]).to eql(["one line summary"])
end

it "returns a map with 'preformatted_proposal' as an array with the network summary'" do
expect(subject.make_proposal({})["preformatted_proposal"]).to eql(["rich_text_summary"])
end
end

describe "#ask_user" do
Yast.import "Wizard"

before do
allow(Yast::Wizard)
end

it "launchs the inst_lan client forcing the manual configuration" do
expect(Yast::WFM).to receive(:CallFunction).with("inst_lan", [{ "skip_detection" => true }])
subject.ask_user({})
end

it "returns a map with 'workflow_sequence' as the result of the client output" do
allow(Yast::WFM).to receive(:CallFunction)
.with("inst_lan", [{ "skip_detection" => true }])
.and_return("result")

expect(subject.ask_user({})).to eql("workflow_sequence" => "result")
end
end
end

0 comments on commit 1039838

Please sign in to comment.