Skip to content

Commit

Permalink
Increase tests for ServiceWidget#content
Browse files Browse the repository at this point in the history
  • Loading branch information
dgdavid committed Jul 31, 2018
1 parent 90a30dd commit 53e05f3
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
15 changes: 15 additions & 0 deletions library/systemd/test/test_helper.rb
Expand Up @@ -6,6 +6,21 @@
Yast.import "SystemdService"
Yast.import "SystemdTarget"

# Find a Term in given content
#
# @param content [Yast::Term] the content in which perform the search
# @param type [Symbol] wanted Term type
# @param id [Symbol] wanted Term id
#
# @return [Yast::Term, nil] a Term when found; nil otherwise
def find_term(content, type, id)
content.nested_find do |term|
next unless term.is_a?(Yast::Term) && term.value == type

term.params.select { |i| i.is_a?(Yast::Term) && i.params == [id] }
end
end

module SystemctlStubs
def stub_systemctl(unit)
case unit
Expand Down
18 changes: 18 additions & 0 deletions library/systemd/test/yast2/service_widget_test.rb
Expand Up @@ -50,6 +50,24 @@
it "returns Term" do
expect(subject.content).to be_a(Yast::Term)
end

it "includes status label" do
status_label = find_term(subject.content, :Label, :service_widget_status)

expect(status_label).to_not be_nil
end

it "includes action selector" do
action_selector = find_term(subject.content, :ComboBox, :service_widget_action)

expect(action_selector).to_not be_nil
end

it "includes start mode selector" do
autostart_selector = find_term(subject.content, :ComboBox, :service_widget_autostart)

expect(autostart_selector).to_not be_nil
end
end

describe "#store" do
Expand Down

0 comments on commit 53e05f3

Please sign in to comment.