Skip to content

Commit bc40ecd

Browse files
committed
test: 增加单元测试
1 parent 60af62d commit bc40ecd

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the Apache 2.0 License
3+
// See the LICENSE file in the project root for more information.
4+
// Maintainer: Argo Zhang([email protected]) Website: https://www.blazor.zone
5+
6+
namespace UnitTest.Components;
7+
8+
public class NetworkMonitorIndicatorTest : BootstrapBlazorTestBase
9+
{
10+
[Fact]
11+
public async Task NetworkMonitorIndicator_Ok()
12+
{
13+
var cut = Context.RenderComponent<NetworkMonitorIndicator>(pb =>
14+
{
15+
pb.Add(a => a.PopoverPlacement, Placement.Top);
16+
});
17+
18+
var com = cut.FindComponent<NetworkMonitor>();
19+
await cut.InvokeAsync(() => com.Instance.TriggerNetworkStateChanged(new NetworkMonitorState
20+
{
21+
IsOnline = true,
22+
NetworkType = "4g",
23+
Downlink = 10.0,
24+
RTT = 50
25+
}));
26+
Assert.DoesNotContain("offline", cut.Markup);
27+
28+
await cut.InvokeAsync(() => com.Instance.TriggerOnlineStateChanged(false));
29+
Assert.DoesNotContain("offline", cut.Markup);
30+
}
31+
}

0 commit comments

Comments
 (0)