Skip to content

Commit a8b6f3a

Browse files
committed
test: 更新单元测试
1 parent 12d10e8 commit a8b6f3a

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

test/UnitTest/Components/OtpInputTest.cs

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ public void OtpInput_Ok()
2323
Assert.Equal(6, items.Count);
2424

2525
var item = items[0];
26-
Assert.Equal("1", item.GetAttribute("value"));
26+
Assert.Contains("value=\"1\"", item.OuterHtml);
27+
item = items[1];
28+
Assert.Contains("value=\"2\"", item.OuterHtml);
2729
}
2830

2931
[Fact]
@@ -42,7 +44,7 @@ public void Readonly_Ok()
4244
pb.Add(a => a.IsReadonly, false);
4345
});
4446
item = cut.Find(".bb-opt-item");
45-
Assert.Equal("<input type=\"number\" class=\"input-number-fix\" inputmode=\"numeric\" blazor:onchange=\"1\">", item.InnerHtml);
47+
Assert.Equal("<input type=\"number\" class=\"bb-opt-item input-number-fix\" inputmode=\"numeric\">", item.OuterHtml);
4648

4749
cut.SetParametersAndRender(pb =>
4850
{
@@ -51,4 +53,25 @@ public void Readonly_Ok()
5153
item = cut.Find(".bb-opt-item");
5254
Assert.Equal("<span class=\"bb-opt-item disabled\"></span>", item.OuterHtml);
5355
}
56+
57+
[Fact]
58+
public void Type_Ok()
59+
{
60+
var cut = Context.RenderComponent<OtpInput>(pb =>
61+
{
62+
pb.Add(a => a.Type, OtpInputType.Text);
63+
pb.Add(a => a.PlaceHolder, "X");
64+
});
65+
66+
var item = cut.Find(".bb-opt-item");
67+
Assert.Equal("<input type=\"text\" class=\"bb-opt-item\" maxlength=\"1\" placeholder=\"X\">", item.OuterHtml);
68+
69+
cut.SetParametersAndRender(pb =>
70+
{
71+
pb.Add(a => a.Type, OtpInputType.Password);
72+
pb.Add(a => a.PlaceHolder, null);
73+
});
74+
item = cut.Find(".bb-opt-item");
75+
Assert.Equal("<input type=\"password\" class=\"bb-opt-item\" maxlength=\"1\">", item.OuterHtml);
76+
}
5477
}

0 commit comments

Comments
 (0)