forked from yast/yast-yast2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
report_test.rb
109 lines (87 loc) · 2.64 KB
/
report_test.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#! /usr/bin/env rspec
#
require_relative "test_helper"
require "yaml"
Yast.import "Report"
Yast.import "Mode"
describe Yast::Report do
before { subject.ClearAll }
describe ".Warning" do
let(:show) { true }
let(:message) { "Message" }
before do
allow(Yast::Mode).to receive(:commandline).and_return(commandline?)
end
context "while in command-line mode" do
let(:commandline?) { true }
it "prints the message only on console" do
expect(Yast::CommandLine).to receive(:Print)
.with(/#{message}/)
expect(Yast::Popup).to_not receive(:Warning)
expect(Yast::Popup).to_not receive(:TimedWarning)
subject.Warning(message)
end
end
context "while in UI mode and timeout is disabled" do
let(:timeout) { 0 }
let(:commandline?) { false }
before(:each) do
subject.DisplayWarnings(show, timeout)
end
it "shows a popup" do
expect(Yast::Popup).to receive(:Warning).with(/#{message}/)
subject.Warning(message)
end
end
context "while in UI mode and timeout is enabled" do
let(:timeout) { 1 }
let(:commandline?) { false }
before(:each) do
subject.DisplayWarnings(show, timeout)
end
it "shows timed popup" do
expect(Yast::Popup).to receive(:TimedWarning).with(/#{message}/, timeout)
subject.Warning(message)
end
end
end
describe ".Error" do
let(:show) { true }
let(:message) { "Message" }
before do
allow(Yast::Mode).to receive(:commandline).and_return(commandline?)
end
context "while in command-line mode" do
let(:commandline?) { true }
it "prints the message only on console" do
expect(Yast::CommandLine).to receive(:Print)
.with(/#{message}/)
expect(Yast::Popup).to_not receive(:Error)
expect(Yast::Popup).to_not receive(:TimedError)
subject.Error(message)
end
end
context "while in UI mode and timeout is disabled" do
let(:timeout) { 0 }
let(:commandline?) { false }
before(:each) do
subject.DisplayErrors(show, timeout)
end
it "shows a popup" do
expect(Yast::Popup).to receive(:Error).with(/#{message}/)
subject.Error(message)
end
end
context "while in UI mode and timeout is enabled" do
let(:timeout) { 1 }
let(:commandline?) { false }
before(:each) do
subject.DisplayErrors(show, timeout)
end
it "shows a timed popup" do
expect(Yast::Popup).to receive(:TimedError).with(/#{message}/, timeout)
subject.Error(message)
end
end
end
end