Skip to content

Commit a2b144e

Browse files
committed
test: 增加单元测试
1 parent 3f6ea91 commit a2b144e

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

test/UnitTest/Components/PopConfirmButtonTest.cs

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,14 @@ public async Task Show_Ok()
2222
pb.Add(a => a.ConfirmButtonColor, Color.Danger);
2323
pb.Add(a => a.Icon, "fa-solid fa-font-awesome");
2424
pb.Add(a => a.Text, "Test_Text");
25+
pb.Add(a => a.CloseButtonIcon, "fa-solid fa-xmark");
26+
pb.Add(a => a.ConfirmButtonIcon, "fa-solid fa-check");
2527
});
2628
});
2729

30+
cut.Contains("fa-solid fa-xmark");
31+
cut.Contains("fa-solid fa-check");
32+
2833
// Show
2934
var button = cut.Find("div");
3035
await cut.InvokeAsync(() =>
@@ -33,7 +38,7 @@ await cut.InvokeAsync(() =>
3338
});
3439

3540
// Close
36-
var buttons = cut.FindAll(".popover-confirm-buttons div");
41+
var buttons = cut.FindAll(".popover-confirm-buttons button");
3742
await cut.InvokeAsync(() =>
3843
{
3944
buttons[0].Click();
@@ -45,7 +50,7 @@ await cut.InvokeAsync(() =>
4550
{
4651
button.Click();
4752
});
48-
buttons = cut.FindAll(".popover-confirm-buttons div");
53+
buttons = cut.FindAll(".popover-confirm-buttons button");
4954
await cut.InvokeAsync(() =>
5055
{
5156
buttons[1].Click();
@@ -97,7 +102,7 @@ await cut.InvokeAsync(() =>
97102
});
98103

99104
// Close
100-
buttons = cut.FindAll(".popover-confirm-buttons div");
105+
buttons = cut.FindAll(".popover-confirm-buttons button");
101106
await cut.InvokeAsync(() =>
102107
{
103108
buttons[0].Click();
@@ -111,7 +116,7 @@ await cut.InvokeAsync(() =>
111116
{
112117
button.Click();
113118
});
114-
buttons = cut.FindAll(".popover-confirm-buttons div");
119+
buttons = cut.FindAll(".popover-confirm-buttons button");
115120
await cut.InvokeAsync(() =>
116121
{
117122
buttons[1].Click();
@@ -132,7 +137,7 @@ await cut.InvokeAsync(() =>
132137
});
133138

134139
// Confirm
135-
buttons = cut.FindAll(".popover-confirm-buttons div");
140+
buttons = cut.FindAll(".popover-confirm-buttons button");
136141
await cut.InvokeAsync(() =>
137142
{
138143
buttons[1].Click();
@@ -158,7 +163,7 @@ await cut.InvokeAsync(() =>
158163
});
159164

160165
// async confirm
161-
buttons = cut.FindAll(".popover-confirm-buttons div");
166+
buttons = cut.FindAll(".popover-confirm-buttons button");
162167
_ = cut.InvokeAsync(() =>
163168
{
164169
buttons[1].Click();
@@ -178,7 +183,7 @@ await cut.InvokeAsync(() =>
178183
});
179184

180185
// async confirm
181-
buttons = cut.FindAll(".popover-confirm-buttons div");
186+
buttons = cut.FindAll(".popover-confirm-buttons button");
182187
await cut.InvokeAsync(() =>
183188
{
184189
buttons[1].Click();
@@ -248,10 +253,12 @@ public void Trigger_Ok()
248253
}
249254

250255
[Fact]
251-
public void ConfirmIcon_Ok()
256+
public void Icon_Ok()
252257
{
253258
var cut = Context.RenderComponent<PopConfirmButtonContent>();
254259
cut.Contains("text-info fa-solid fa-circle-exclamation");
260+
cut.Contains("fa-solid fa-xmark");
261+
cut.Contains("fa-solid fa-check");
255262
}
256263

257264
[Fact]

0 commit comments

Comments
 (0)